Articles on Trending Technologies

Technical articles with clear explanations and examples

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

Amit D
Amit D
Updated on 11-Mar-2026 1K+ 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:   $(document).ready(function(){       $(document).ready(function(){          $("button.button1").attr("myid", "myvalue");            $('button').on('click', function() {                     if (this.hasAttribute("myid")) {                alert('True: The new attribute added successfully.')             } else {                alert('False')             }           })       });   });           Button 1    

Read More

What are generator functions in JavaScript?

Prabhas
Prabhas
Updated on 11-Mar-2026 327 Views

Generator Functions allows execution of code in between when a function is exited and resumed later. So, generators can be used to manage flow control in a code. Cancel asynchronous operations easily since execution can be paused anytime.Here’s the syntax; do not forget to add an asterisk after the “function” keyword. You can add an asterisk using any of the following −function *myFunction() {} // or function* myFunction() {} // or function*myFunction() {}ExampleLet’s see how to use a generator function                    function* display() {             var ...

Read More

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

Amit D
Amit D
Updated on 11-Mar-2026 325 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:                          $(document).ready(function() {             $("#buttonSet").click(function () {                           $("#buttonGet").removeAttr('disabled');             });             $("#buttonGet").click(function () {               $("#result").html(               $("#txtBox").val() + "" +               $("input:radio[name=rd]:checked").val()             );          });          });                     Name                   Gender       Male       Female                            

Read More

How to set “checked” for a checkbox with jQuery?

Amit D
Amit D
Updated on 11-Mar-2026 2K+ Views

Use the checked attribute to set the checkbox with jQuery. Also, the prop() method is used to get the property value.ExampleYou can try to run the following code to learn how to set checked for a checkbox:   jQuery Example     b {      color: green;   }       Check/ Uncheck this checkbox   $( "input" ).change(function() {   var $input = $( this );   $( "p" ).html(     ".attr( "checked" ): " + $input.attr( "checked" ) + "" +     ".prop( "checked" ): " + $input.prop( "checked" ) + "" +     ".is( ":checked" ): " + $input.is( ":checked" ) + "" ); }).change();  

Read More

How do we use # in jQuery Attribute Selector?

Amit D
Amit D
Updated on 11-Mar-2026 382 Views

To use # in jQuery attribute selector, include # under *= . This will find the attribute with #.ExampleYou can try to run the following code to learn how to use # in jQuery attribute selector:     $(document).ready(function()  {        $( "div[myattr*='#']" ).css("background-color", "yellow");     }); Java HTML Ruby

Read More

How do we use jQuery Attribute selector with a period?

Amit D
Amit D
Updated on 11-Mar-2026 336 Views

jQuery Attribute selector is used to select elements with the specified attribute and value. You can easily use it with a period (.) or a hash (#).ExampleYou can try to run the following code to learn how to use jQuery selector with a period: $(document).ready(function(){    $( "div[myattr*='.']" ).css("background-color", "yellow");   }); Java HTML Ruby

Read More

How do we use wildcard or regular expressions with a jQuery selector?

David Meador
David Meador
Updated on 11-Mar-2026 2K+ Views

Wildcard or regular expressions can also be used with jQuery selector for id of element.ExampleYou can try to run the following code to use wildcard or regular expressions with jQuery selector: $(document).ready(function(){    $("[id^=sub]").css("background-color", "green"); }); Java HTML Ruby

Read More

Usage of rest parameter and spread operator in JavaScript?

Anjana
Anjana
Updated on 11-Mar-2026 380 Views

Rest ParameterWith rest parameter, you can represent a number of arguments as an array. ES6 brought rest parameter to ease the work of developers. For arguments objects, rest parameters are indicated by three dots … and precedes a parameter.Let’s see the following code snippet to define rest parameter −                    function addition(…numbers) {             var res = 0;             numbers.forEach(function (number) {                res += number;             });     ...

Read More

What are the latest operators added to JavaScript?

Ayyan
Ayyan
Updated on 11-Mar-2026 145 Views

The latest operators added to JavaScript are spread operator and rest.Rest operatorWith rest parameter, you can represent number of arguments as an array. ES6 brought rest parameter to ease the work of developers. For arguments objects, rest parameters are indicated by three dots … and preceds a parameter.ExampleLet’s see the following code snippet to define rest parameter                    function addition(…numbers) {             var res = 0;             numbers.forEach(function (number) {                res += number;   ...

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 11-Mar-2026 2K+ 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 going for elements with an ID ending with the string “new1”. $(document).ready(function(){   $("[id$=new]").css("background-color", "yellow");     }); Java HTML Ruby

Read More
Showing 351–360 of 61,248 articles
« Prev 1 34 35 36 37 38 6125 Next »
Advertisements