- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 8895 Articles for Front End Technology
![Ricky Barnes](https://www.tutorialspoint.com/assets/profiles/13354/profile/60_84969-1512590781.jpg)
3K+ Views
To find anchor tag in div, use a selector and the addClass() method adds a class using jQuery.You can try to run the following code to learn how to find anchor tag in div and add class:Live Demo $(document).ready(function(){ $("#button1").click(function(){ $('#div1 a').addClass('myclass'); }); }); .myclass { font-size: 25px; } Demo This is demo text. Click
![Ricky Barnes](https://www.tutorialspoint.com/assets/profiles/13354/profile/60_84969-1512590781.jpg)
1K+ Views
To add and remove a class to an anchor tag, use the toggleClass. Using it you can add and remove a class on a click.You can try to run the following code to learn how to add and remove a class to an anchor tag with jQuery −ExampleLive Demo $(document).ready(function(){ $("#mylink").click(function (e) { e.preventDefault(); $(this).toggleClass("selected"); }); }); .selected { color: red; } Click me The above will add and remove class (change color) on click.
![Ricky Barnes](https://www.tutorialspoint.com/assets/profiles/13354/profile/60_84969-1512590781.jpg)
560 Views
The jQuery attr() method is used to get the value of an attribute. It can also be used to set new value. We will set new value of attribute href to tutorialspoint.com/html5 from tutorialspoint.com/css.You can try to run the following code to learn how to set new value for an attribute in jQuery −ExampleLive Demo Selector Example $(document).ready(function(){ $("button").click(function(){ $("#tpoint").attr("href", "https://www.tutorialspoint.com/html5"); }); ... Read More
![Ricky Barnes](https://www.tutorialspoint.com/assets/profiles/13354/profile/60_84969-1512590781.jpg)
7K+ Views
The jQuery attr() method is used to get the value of an attribute. It can also be used to change the value. In the example, we will change the attribute value tutorialspoint.com to tutorialspoint.com/java.You can try to run the following code to learn how to change the value of an attribute using jQuery −ExampleLive Demo Selector Example $(document).ready(function(){ $("button").click(function(){ $("#tpoint").attr("href", "https://www.tutorialspoint.com/java"); }); }); tutorialspoint.com Change attribute value The value of above link will change on clicking the above button. Check before and after clicking the link.
![David Meador](https://www.tutorialspoint.com/assets/profiles/13351/profile/60_165994-1512670078.jpg)
342 Views
The jQuery attr() method is used to get the value of an attribute, with the attribute, for example, href. Mention the attribute as the parameter of the attr() method.You can try to run the following code to learn how to use the attr() method to get the value of an attribute:ExampleLive Demo Selector Example $(document).ready(function(){ $("button").click(function(){ alert($("#tpoint").attr("href")); }); }); Website tutorialspoint Show complete link
![Amit D](https://www.tutorialspoint.com/assets/profiles/13349/profile/60_63530-1512538715.jpg)
1K+ 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($('#my_id').data('original-title')); }); Demo
![Amit D](https://www.tutorialspoint.com/assets/profiles/13349/profile/60_63530-1512538715.jpg)
4K+ 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($('#myimg').attr('src')); }); Logo
![Amit D](https://www.tutorialspoint.com/assets/profiles/13349/profile/60_63530-1512538715.jpg)
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(){ $("button").click(function(){ alert($("img").attr("height")); }); }); Get the height
![Amit D](https://www.tutorialspoint.com/assets/profiles/13349/profile/60_63530-1512538715.jpg)
342 Views
With jQuery, you can easily select multiple elements. Here’s how you can select for multiple elements such as and ,$("h1, p")You can try to run the following code to learn how to select multiple elements with jQuery −ExampleLive Demo jQuery Example $(document).ready(function() { $("h1, p").css("color", "green"); }); Heading This is demo text.