Amit D has Published 118 Articles

How to use jQuery to get the value of HTML attribute of elements?

Amit D

Amit D

Updated on 18-Dec-2019 08:20:27

173 Views

To get the value of html attribute, use the val() method.ExampleYou can try to run the following code to learn how to use jQuery to get the value of HTML attribute of elements:Live Demo                          $(document).ready(function() ... Read More

How can I add an attribute into specific HTML tags in jQuery?

Amit D

Amit D

Updated on 18-Dec-2019 08:19:15

858 Views

Use the attr() method to add an attribute into specific HTML tags in jQuery.ExampleYou can try to run the following code to learn how to add an attribute into specific HTML tags:Live Demo   $(document).ready(function(){       $(document).ready(function(){          $("button.button1").attr("myid", "myvalue");   ... Read More

How to use jQuery selectors on custom data attributes using HTML5?

Amit D

Amit D

Updated on 18-Dec-2019 08:16:25

228 Views

To use jQuery selectors on custom data attributes, you can use contains, starts with, and ends with for the HTML data attributes.ExampleOther than that, you can try to run the following code to learn how to use jQuery selectors on custom data attributes using HTML5:Live Demo ... Read More

How to use jQuery selector for the elements with an ID that ends with a given string?

Amit D

Amit D

Updated on 18-Dec-2019 08:15:42

1K+ Views

To get the elements with an ID that ends with a given string, use attribute selector with $ character.ExampleYou can try to run the following code to learn how to to use jQuery selector for the elements with an ID that ends with a given string. Let’s say we are ... Read More

How to get a DOM Element from a jQuery Selector?

Amit D

Amit D

Updated on 18-Dec-2019 07:53:30

718 Views

To get a DOM Element from a jQuery Selector, use the $('#element').get(0). This returns the DOM element.ExampleYou can try to run the following code to learn how to get a DOM Element from a jQuery Selector. For our checkbox example, get a DOM element like the following code:Live Demo ... Read More

How to exclude first and second element from jQuery selector?

Amit D

Amit D

Updated on 18-Dec-2019 07:43:21

629 Views

To exclude first and second element from jQuery, use the slice() method.ExampleYou can try to run the following code to exclude first and element from jQuery:Live Demo $(document).ready(function(){    $('p').slice(2).css('font-size', '24px'); }); Java C++ Ruby Groovy

How do we use .not() with jQuery selector?

Amit D

Amit D

Updated on 18-Dec-2019 07:42:10

141 Views

The .not() is used to select all elements except an element, which can be specified.ExampleYou can try to run the following code to learn how to use .not()  with jQuery selector.Live Demo $(document).ready(function(){   $("p:not(.myclass)").css("background-color", "red"); }); Heading This is demo ... Read More

How to write a jQuery selector to find links with # in href attribute?

Amit D

Amit D

Updated on 18-Dec-2019 07:34:31

3K+ Views

ExampleYou can try to run the following code to write a jQuery selector to find links with # in href. Here, ^ is used to find links starting with # in href.Live Demo $(document).ready(function(){    $('a[href^="#"]').click(function(){       alert('Success! Selected link starting with # ... Read More

How to escape square brackets in jQuery selector?

Amit D

Amit D

Updated on 18-Dec-2019 07:33:37

292 Views

To escape square brackets in jQuery selectors is quite easy. Let’s see with an example of escaping the brackets in the name of the box.ExampleWhatever you will select, will get added to the textarea on button click.Live Demo $(document).ready(function() {     $("#addnow").click(function () ... Read More

How does jQuery.slice() method work in jQuery?

Amit D

Amit D

Updated on 18-Dec-2019 07:24:59

76 Views

The slice(start, end) method selects a subset of the matched elements. The following are the parameters of the slice() method:start − Where to start the subset. The first element is at zero. Can be negative to start from the end of the selection.end − Where to end the subset excluding end element. ... Read More

Previous 1 ... 5 6 7 8 9 ... 12 Next
Advertisements