Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
jQuery Articles - Page 70 of 73
2K+ Views
To get the value in jQuery, use the data-attributes with the data() method. You can try to run the following code to implement how to get the value of custom attribute:ExampleLive Demo
Selector Example
(document).ready(function() {
alert((document).ready(function() {
alert(('#my_id').data('original-title'));
});
Demo
5K+ Views
To get the value of src attribute in jQuery is quite easy. We will get the src attribute of the img tag. This attribute has the URL of the image. Let’s first see how we can add jQuery −You can try to run the following code to learn how to get the value of src attribute in jQuery −ExampleLive Demo
Selector Example
(document).ready(function() {
alert((document).ready(function() {
alert(('#myimg').attr('src'));
});
Logo
2K+ Views
Use jQuery attr() method to get the value of id attribute. You can try to run the following code to learn how to get the value in jQuery −ExampleLive Demo
jQuery Example
(document).ready(function() {
alert((document).ready(function() {
alert(('#div1').attr('id'));
});
This is demo text.
2K+ Views
To get an attribute value in jQuery is quite easy. For this, use the jQuery attr() method. You can try to run the following code to learn how to get an attribute value in jQuery −ExampleLive Demo jQuery Example (document).ready(function(){(document).ready(function(){("button").click(function(){ alert($("img").attr("height")); }); }); Get the height
438 Views
With jQuery, you can easily select multiple elements. Here’s how you can select for multiple elements such as and ,("h1,p")YoucantrytorunthefollowingcodetolearnhowtoselectmultipleelementswithjQuery−ExampleLiveDemojQueryExample(document).ready(function() { $("h1, p").css("color", "green"); }); Heading This is demo text.
333 Views
To select a single element which matches with the given ID using jQuery, use the element id selector. Here’s how,('#elementid')You can try to run the following code to learn how to select a single element which matches with the given ID using jQuery −ExampleLive Demo
Selector Example(document).ready(function() {
/* This would select second division only*/
$("#div2").css("background-color", "yellow");
});
This is first division of the DOM.
This is second division of the DOM.
This is third division of the DOM
184 Views
Yes, it is possible to use (this)anduniversalselector(∗)withjQuery.Let′sseehowtodoit.YoucantrytorunthefollowingcodetolearnhowtousethisanduniversalselectorwithjQuery:ExampleLiveDemojQueryUniversalSelector(document).ready(function() { $('*', this).css("background-color", "yellow"); }); This is first division of the DOM. This is second division of the DOM.
346 Views
The universal selector selects all the elements available in the document. Here’s how to use it:(′∗′)ExampleYoucantrytorunthefollowingcodetolearnhowtoimplementUniversalSelectorinjQuery−LiveDemojQueryUniversalSelector(document).ready(function() { /* This would select all the elements */ $("*").css("background-color", "yellow"); }); This is first division of the DOM. This is second division of the DOM. This is third division of the DOM
596 Views
A jQuery Selector is a function which makes use of expressions to find out matching elements from a DOM based on the given criteria. We can easily combine a class selector and an attribute selector with jQuery.You can try to run the following code to learn how to How to combine a class selector and an attribute selector with jQuery −ExampleLive Demo (document).ready(function() {('.myclass[reference="12345"]').css("background-color", "yellow"); }); Row 1 Column 1 Row 2 Column 1 Row 3 Column 1
5K+ Views
To find an element based on a data-attribute value using jQuery is quite easy. Try to run the following code to find an element based on a data-attribute value −ExampleLive Demo (document).ready(function() {('[data-slide="0"]').addClass('demo'); }); .demo { font-size: 150%; color: red; } Rocky Amit John