How to set attributes of an element using jquery?



How to set attributes of an element using jquery?..

Answer / Balwant Kumar Singh

To set attributes of an element using jQuery, you can use the `attr()` method. Here is an example:

```html
<div id='myDiv'>This is the div</div>

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function() {
$('#myDiv').attr('title', 'New Title');
});
</script>

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More jQuery Interview Questions

How we can select multiple elements in jquery?

1 Answers  


What is the advantage of using protocol less URL while referencing jQuery from CDNs?

1 Answers  


Tell me an example usage of jquery mobile? : jquery mobile

1 Answers  


How do you check if an element is empty?

1 Answers  


How can you disable jquery animation?

1 Answers  


What is the use of jQuery filter?

1 Answers  


Explain the features of jquery mobile? : jquery mobile

1 Answers  


What does $("div") will select?

1 Answers  


How does caching helps and how to use caching in jQuery?

1 Answers  


What is the use of each function in jQuery?

1 Answers  


What does dollar sign ($) me in jquery?

1 Answers  


How you will use jquery means requirement needed for using jquery.

1 Answers  


Categories