In this tutorial , we will discuss about the different methods to select elements of html page. The jQuery has two ways to select elements. The first uses a combination of CSS and XPath selectors passed as a string to the jQuery constructor (eg. $("div > ul a")). The second uses several methods of the jQuery object. Both approaches can be combined.
For example ,we want to select a list which has an ID "orderedlist" in the given html code. We can do it by two different ways :
First , by highlighting background color of the text, using following code lines (custom.js) :
Above code highlight the text background area by "red" color .The code below is used to highlight the text color to blue :
In Second way, when you hover the mouse on text, the text color changes to green to show selection. The code for this is(custom.js) :
The html file code :
Output when highlighting background color to red :
Output when highlighting text color to blue :
Output when mouse hover changes color of text to green :
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.