Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Front End Technology Articles
Page 594 of 652
How to write a jQuery selector to find links with # in href attribute?
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 # in href.'); }); }); Demo C++
Read MoreHow to escape square brackets in jQuery selector?
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 () { $("#myselect :selected").each(function () { $("#text").val($("#text").val() + $(this).text() + ""); }); }); }); email@example.com David Select and Click to Add
Read MoreWhat is the difference between jQuery add() & jQuery append() methods in jQuery?
jQuery add() methodIf you want to add element to an existing group of elements, then use the add() method.ExampleYou can try to run the following code to learn how to work with jQuery.add() method:Live Demo $(document).ready(function(){ $("h1").add("span").css("background-color", "yellow"); }); Tutorialspoint Text Tutorials for free. Video Tutorials for free. jQuery append() methodThe append() method appends content to the inside of every matched element.ExampleYou can try to run the following code to learn how to work with jQuery append() method:Live Demo ...
Read MoreHow to traverse Data Object Model (DOM) nodes using jQuery?
jQuery traversing is used to find elements based on what is their relation twith other elements. You need to begin with one selection and move ahead till you the reach the elements you want.jQuery is a very powerful tool which provides a variety of DOM traversal methods to help us select elements in a document randomly as well as in sequential method.Let’s filter out the elements by traversing. The filter( selector ) method can be used to filter out all elements from the set of matched elements that do not match the specified selector(s).ExampleThe selector can be written using any ...
Read MoreHow to filter object array based on attributes in jQuery?
To filter object array based on attributes in jQuery, use the map() method with JSON.ExampleYou can try to run the following code to learn how to filter object array based on attributes in jQuery,Live Demo $(document).ready(function(){ $(document).ready(function(){ var json ={"DEPARTMENT": [ { "id":"1", "deptemp":"840", "shares":"1100", }, { "id":"2", "deptemp":"1010", "shares":"1900", }, { "id":"1", "deptemp":"350", "shares":"510", }, { "id":"2", "deptemp":"575", "shares":"1900", }]}; json.DEPARTMENT = $.map(json.DEPARTMENT,function(val,key) { if(Number(val.deptemp) = 500) return val; }); for(var i in json.DEPARTMENT) $("p").html("Department Employees: "+json.DEPARTMENT[i].deptemp+" , Shares:"+json.DEPARTMENT[i].shares) }); });
Read MoreJavaScript symbol.description property
The symbol.description property in JavaScript converts a Symbol object to a primitive value. The syntax is as follows −Symbol()[Symbol.toPrimitive](hint);Example Live Demo Demo Heading Click to display... Result function display() { const val = Symbol('john'); console.log(val[Symbol.toPrimitive]); } OutputClick the “Result” button −Example Live Demo Demo Heading Click to display... Result function display() { const val = Symbol(2465); var res = val[Symbol.toPrimitive](99); console.log(res) } OutputClick the “Result” button and get the result in Console −
Read MoreWhat is the difference between jQuery.children( ) and jQuery.siblings( ) in jQuery?
jQuery children() methodThe children( [selector] ) method gets a set of elements containing all of the unique immediate children of each of the matched set of elements.Here is the description of all the parameters used by this method −selector − This is an optional argument to filter out all the childrens. If not supplied then all the childrens are selected.ExampleYou can try to run the following code to learn how to work with jQuery children() method:Live Demo jQuery children() method $(document).ready(function(){ ...
Read MoreWhat is the difference between jQuery.map() and jQuery.grep() Functions in jQuery?
The jQuery map function translates a set of elements in the jQuery object into another set of values in a jQuery array which may, or may not contain elements. The grep() function is used to find an element of an array. The difference is we use $.grep to filter an array and $.map to apply a function to each item in the array.jQuery map functionThe map method translates a set of elements in the jQuery object into another set of values in a jQuery array which may, or may not contain elements.The following are the parameters of jQuery.map() method:callback − ...
Read MoreHow to set width and height of an element using jQuery?
To set the width and height of an element using jQuery, use the width() and height() in jQuery.Width of an elementExampleYou can try to run the following code to learn how to set the width of an element in jQuery:Live Demo $(document).ready(function(){ $("#button1").click(function(){ $("div").width(300); }); $("#button2").click(function(){ $("div").width(400); }); }); Width of div: 300 Width of div: 400 Height of an elementExampleYou can try to run the following code to learn how to set the ...
Read MoreHow jQuery selects elements using CSS?
jQuery uses CSS selector to select elements using CSS. Let us see an example to return a style property on the first matched element. The css( name ) method returns a style property on the first matched element.Here is the description of all parameter used by this method −name − The name of the property to access.ExampleYou can try to run the following code to learn how jQuery selects elements with CSS:Live Demo jQuery Example $(document).ready(function() { ...
Read More