Selectors are a feature in HTML5 and CSS3 that allow for efficient and flexible dynamic web page creation. They allow users to select elements on a webpage based on their natural language. This makes creating HTML, CSS and JavaScript much easier.
When creating webpages, designers most commonly use a list of elements or components. These elements include text, images and links to navigate the webpage. However, HTML lacks syntactic tags for these components. So, developers had to come up with their own way of specifying component types. That is where Selectors came in- they revolutionized the way websites were created. Now, anyone can see and easily create websites using natural language instead of code syntax.
Selectors help us navigate through our webpage creation process with natural language. For instance, you can navigate through your webpage using phrases such as 'show all text elements,' 'show all image elements' or 'show all links.' These phrases can be expressed using different natural language elements such as 'the + element combination,' 'the element' and 'the element.' The possibilities are endless when it comes to specifying the elements you want to include on your webpage with Selectors.
Since Selectors are used by both developers and non-developers alike, it's great for efficiency as well as flexibility. For developers, Selectors make it easy to create efficient webpages with minimal code. Plus, they're easy to modify and extend thanks to JavaScript which allows for customization via plugins and extensions. This makes creating HTML, CSS and JS much easier and allows for greater creativity by anyone with access to a computer and an internet connection.
Having access to Selectors drastically changed the way we design websites both functionally and aesthetically. They make it much easier for novices to create dynamic webpages using natural language. Furthermore, they're great for efficiency since they allow for easy customization as well as granular targeting capabilities. Therefore, we cannot thank jQuery enough for giving us something so revolutionary!
We have two paragraphs with two types of input, one of type password and another image. We modify the width using css in jquery selecting the password input in position 0 and the image input in position 1.
<script>
$(document).ready(function(){
$(':password').eq(0).css('width', '300px');
$(':image').eq(1).css('width', '300px');
});
</script>
We have two inputs of type text, and headers of type h1, h2 and h3. With jQuery we select from the input of type text the equivalent to the number 0 and we insert the value 'Your Login'. We also select all the headers and we apply the red color to them.
<script>
$(document).ready(function(){
$(':text').eq(0).val('Your Login');
$(':header').css('color', 'red');
});
</script>
We use parent to select the children of the selected elements.
We have 3 possible cases:
<script>
$(document).ready(function(){
$("tr:parent").css('color', 'red');
$("#mySel:parent").css('color', 'blue');
$(".selClass:parent").css('color', 'orange');
});
</script>
We will use the visible, hidden and eq selectors in three possible cases in this example:
<script>
$(document).ready(function(){
$('img:visible').css('width', '200px');
$("img:hidden").show();
$('img:visible').eq(3).hide();
});
</script>
Tips on SEO and Online Business
Next Articles
Previous Articles