How do I check if an element is hidden in jQuery?
How do I toggle the visibility of an element using .hide() , .show() , or .toggle() ? How do I test if an element is visible or hidden ?
選取、修改、事件、表單,jQuery 與前端框架。
57 / 57 題 · 依票數排序
How do I toggle the visibility of an element using .hide() , .show() , or .toggle() ? How do I test if an element is visible or hidden ?
How can I redirect the user from one page to another using jQuery or pure JavaScript?
I'd like to check if the user input is an email address in JavaScript, before sending it to a server or attempting to send an email to it, to prevent the most basic mistyping. How…
I need to check the checked property of a checkbox and perform an action based on the checked property using jQuery. For example, if the age checkbox is checked, then I need to sh…
I'd like to do something like this to tick a checkbox using jQuery : $(".myCheckBox").checked(true); or $(".myCheckBox").selected(true); Does such a thing exist?
Suppose I'm familiar with developing client-side applications in jQuery , but now I'd like to start using AngularJS . Can you describe the paradigm shift that is necessary? Here a…
The following are two methods of building a link that has the sole purpose of running JavaScript code. Which is better, in terms of functionality, page load speed, validation purp…
How do I copy text to the clipboard (multi-browser)? Related: How does Trello access the user's clipboard?
How can I change the class of an HTML element in response to an onclick or any other events using JavaScript?
Mod note : This question is about why XMLHttpRequest / fetch /etc. on the browser are subject to the Same Access Policy restrictions (you get errors mentioning CORB or CORS) while…
When I want to prevent other event handlers from executing after a certain event is fired, I can use one of two techniques. I'll use jQuery in the examples, but this applies to pl…
What I am looking for: A way to style one HALF of a character. (In this case, half the letter being transparent) What I have currently searched for and tried (With no luck): Metho…
How can I check the existence of an element in jQuery? The current code that I have is this: if ($(selector).length > 0) { // Do something } Is there a more elegant way to approac…
I would like to upload a file asynchronously with jQuery. $(document).ready(function () { $("#uploadbutton").click(function () { var filename = $("#file").val(); $.ajax({ type: "P…
I'd like to store a JavaScript object in HTML5 localStorage , but my object is apparently being converted to a string. I can store and retrieve primitive JavaScript types and arra…
Is there a way I can modify the URL of the current page without reloading the page? I would like to access the portion before the # hash if possible. I only need to change the por…
I have two radio buttons and want to post the value of the selected one. How can I get the value with jQuery? I can get all of them like this: $("form :radio") How do I know which…
I have some HTML menus, which I show completely when a user clicks on the head of these menus. I would like to hide these elements when the user clicks outside the menus' area. Is…
I'm trying to open a URL in a new tab, as opposed to a popup window. I've seen related questions where the responses would look something like: window.open(url,'_blank'); window.o…
How do I refresh a page using JavaScript?
I have this input element: <input type="text" class="textfield" value="" id="subject" name="subject"> Then I have some other elements, like other tag's & <textarea> tag's, etc...…
How do I determine if a variable is undefined or null ? My code is as follows: var EmpName = $("div#esd-names div#name").attr('class'); if(EmpName == 'undefined'){ // DO SOMETHING…
I'm using jQuery to add an additional row to a table as the last row. I have done it this way: $('#myTable').append('<tr><td>my data</td><td>more data</td></tr>'); Are there limit…
$input.disabled = true; or $input.disabled = "disabled"; Which is the standard way? And, conversely, how do you enable a disabled input?
I have a very simple JavaScript array that may or may not contain duplicates. var names = ["Mike","Matt","Nancy","Adam","Jenny","Nancy","Carl"]; I need to remove the duplicates an…
How can I get the selected text (not the selected value) from a drop-down list in jQuery?
So jQuery 1.6 has the new function prop() . $(selector).click(function(){ //instead of: this.getAttribute('style'); //do i use: $(this).prop('style'); //or: $(this).attr('style');…
How can I get windowWidth , windowHeight , pageWidth , pageHeight , screenWidth , screenHeight , pageX , pageY , screenX , screenY which will work in all major browsers?
I have a script that uses $(document).ready , but it doesn't use anything else from jQuery. I'd like to lighten it up by removing the jQuery dependency. How can I implement my own…
How do I get the selected value from a dropdown list using JavaScript? <form> <select id="ddlViewBy"> <option value="1">test1</option> <option value="2" selected="selected">test2<…
I have a layout similar to this, and would like to use a jQuery selector to select the child img inside the div on click. <div id="..."> <img src="..."> </div> To get the div , I'…
I want to know how to get the X and Y position of HTML elements such as img and div in JavaScript.
With React Router , I can use the Link element to create links which are natively handled by React Router. I see internally it calls this.context.transitionTo(...) . I want to do…
I want to be able to preview a file (image) before it is uploaded. The preview action should be executed all in the browser without using Ajax to upload the image. How can I do th…
I'm trying to do something like the following in React JSX (where ObjectRow is a separate component): <tbody> for (var i=0; i < numrows; i++) { <ObjectRow/> } </tbody> I realize a…
How do I scroll to the top of the page using JavaScript? The scrollbar instantly jumping to the top of the page is desirable too as I'm not looking to achieve smooth scrolling.
How does data binding work in the AngularJS framework? I haven't found technical details on their site . It's more or less clear how it works when data is propagated from view to…
Is it possible that using jQuery, I cancel/abort an Ajax request that I have not yet received the response from?
Is there a way to detect whether or not a user is using a mobile device in jQuery? Something similar to the CSS @media attribute? I would like to run a different script if the bro…
When embedding JavaScript in an HTML document, where is the proper place to put the <script> tags and included JavaScript? I seem to recall that you are not supposed to place thes…
I would like to move one DIV element inside another. For example, I want to move this (including all children): <div id="source"> ... </div> into this: <div id="destination"> ...…
With jQuery, we all know the wonderful .ready() function: $('document').ready(function(){}); However, let's say I want to run a function that is written in standard JavaScript wit…
I am using setInterval(fname, 10000); to call a function every 10 seconds in JavaScript. Is it possible to stop calling it on some event? I want the user to be able to stop the re…
How do I convert all elements of my form to a JavaScript object? I'd like to have some way of automatically building a JavaScript object from my form, without having to loop over…
I'm trying to direct a browser to a different page. If I wanted a GET request, I might say document.location.href = 'http://example.com/q=a'; But the resource I'm trying to access…
I have an element that already has a class: <div class="someclass"> ... </div> How can i add a class to the div (not replace, but add) with JavaScript?
Why would someone prefer either the Lodash or Underscore.js utility library over the other? Lodash seems to be a drop-in replacement for underscore, the latter having been around…
I would like to find out, in JavaScript, which element currently has focus. I've been looking through the DOM and haven't found what I need, yet. Is there a way to do this, and ho…
I have a bit of code where I am looping through all the select boxes on a page and binding a .hover event to them to do a bit of twiddling with their width on mouse on/off . This…
Given an array [1, 2, 3, 4] , how can I find the sum of its elements? (In this case, the sum would be 10 .) I thought $.each might be useful, but I'm not sure how to implement it.
How do I create a div element in jQuery ?
I have a table column I’m trying to expand and hide. jQuery seems to hide the <td> elements when I select it by class but not by the element’s name . For example: $(".bold").hide(…
I'm using $.post() to call a servlet using Ajax and then using the resulting HTML fragment to replace a div element in the user's current page. However, if the session times out,…
What is the reason browsers do not correctly recognize: <script src="foobar.js" /> <!-- self-closing script element --> Only this is recognized: <script src="foobar.js"></script>…
How can I check if a checkbox in a checkbox array is checked using the id of the checkbox array? I am using the following code, but it always returns the count of checked checkbox…
What does the ... do in this React (using JSX) code and what is it called? <Modal {...this.props} title='Modal heading' animation={false}>
How do I check if an element exists if the element is created by .append() method? $('elemId').length doesn't work for me.
沒有符合的題目。