Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
jQuery Articles
Page 39 of 42
How to check if onClick exists on element in jQuery?
These codes might help you −$('body').click(function(){ alert('test' )}) var foo = $.data( $('body').get(0), 'events' ).click // you can query $.data( object, 'events' ) and get an object back, then see what events are attached to it. $.each( foo, function(i,o) { alert(i) // guid of the event alert(o) // the function definition of the event handler });
Read MoreWhat is the difference between $.closest() and $.parents() methods in jQuery?
The jQuery closest and parents method is used to set or get the first or all ancestor element, matching the selector. Let's see the difference below: jQuery closest() method The closest() method begins with the current element and returns only the first ancestors matching the passed expression. This returned jQuery object has zero or one element. Example You can try to run the following code to learn how to work with jQuery closest method − .myclass * { display: block; border: 2px solid blue; color: red; padding: 5px; margin:10px; } ...
Read MoreHow to get and set form element values with jQuery?
To get a form value with jQuery, you need to use the val() function. To set a form value with jQuery, you need to use the val() function, but to pass it a new value. Example You can try to run the following code to learn how to get and set form element values with jQuery − $(document).ready(function(){ $("#buttonSet").click(function () { $("#txtBox").val("Amit"); $("input:radio").val(["male"]); $("#buttonGet").removeAttr('disabled'); }); $("#buttonGet").click(function () { $("#result").html( $("#txtBox").val() + "<br/>" + $("input:radio[name=rd]:checked").val() ); }); }); Name Gender Male Female
Read MoreHow to get the closest input value from clicked element with jQuery?
To get the closest input value from clicked element with jQuery, follow the steps − You need to use closest to find the closest ancestor matching the given. Now, find the input with the given name using the attribute equals selector. The last step is to use val() metjod to retrieve the value of the input. Let's first see how to add jQuery − Example You can try to run the following code to get closest input value from clicked element with jQuery − $(document).ready(function(){ $(".add").on("click", function () { var v = $(this).closest("div.content").find("input[name='rank']").val(); ...
Read MoreWhat is the difference between text() and html() in jQuery?
jQuery comes with a lot of methods to manipulate attributes. These are DOM related methods. The attributes include, text() and html() too, text() – This method sets or returns the text content of elements selected. html() – This method sets or returns the content of elements selected. Example You can try to run the following code to learn how to manipulate attributes with text() and html() methods − $(document).ready(function(){ $("#button1").click(function(){ alert("Using text()- " + $("#demo").text()); }); $("#button2").click(function(){ alert("Using html()- " + $("#demo").html()); }); }); This is demo text. Text HTML
Read MoreHow to get innerHTML of a div tag using jQuery?
To get the innerHTML of a div tag in jQuery, use the class with innerHTML. You can try to run the following code to learn how to get innerHTML of a div tag using jQuery −ExampleLive Demo $(document).ready(function(){ $("#button1").click(function(){ var one = $('.a').innerHTML; alert(one); }); }); Value one Get
Read MoreHow to call a jQuery plugin function outside the plugin?
jQuery is a JavaScript library introduced to make development with JavaScript easier. It reduces the development time. Let us see how to call a jQuery plugin function outside the plugin.For calling, wrap the jQuery method for returning the instance of the constructor. Call prototype methods on it.example$.fn.myFunction = function(config){ return new myFunction (config); };Instance the plugin and call the method −var plugin = $('#someSelector').myFunction(); plugin.setToken(column);
Read MoreHow to use FastClick with jQuery Mobile the right way in HTML?
There is no need to use 3rd party plugins like Fastclick. jQuery Mobile solved this with vclick event.JQuery works well on mobile and desktop and don’t have 300 ms delay$(document).on('vclick', '#impButton', function(){ });
Read MoreEffects and animations with Google Maps markers in HTML5
There is no way to fade markers through API.However, markers can be simulated by creating Custom Overlay.Custom overlay usually contains a div with the help of which opacity can be controlled by javascript or jquery.In order to create effects or animations over Google Maps markers, we need a custom overlay.The marker can be added to map and it surely makes optimized: false optionvar newmarkerimg= $('#map_canvas img[src*="iconmarker "][class!="imageadjust "]');
Read MorejQuery Mobile: Sending data from one page to the another
To pass values, let us say our is the following, with page new.html,StructureThe JS will be:$( document ).on( "pageinit", "#new", function( event ) { var myParam = $(this).data("url").split("?")[1]; myParam = parameters.replace("structure=",""); alert(myParam); });
Read More