Thursday, July 8, 2010

jQuery, Multiple Selectors

With jQuery you can specify more than one selector at once and manipulate them as you wish.
Syntax:
$('selector1, selector2,etc.').css('propertyName', 'propertyValue');

See below a Script and a Demo.











<html>
<head>
<style type='text/css'>


</style>

<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'></script>
<script type='text/javascript'>
$(document).ready(function(){
$('div#dx,span.ita').css('background','orange')
.css('border','dotted 2px red')

})
</script>
</head>

<body>

<div>This is a div tag...not affected by the jQuery...</div>
<div id='dx'>This is a div with an id...</div>
<b>This a blod tag...also not affected by the jQuery</b><br>
<span class='ita'>This is span tag...</span>
</body>
</html>







This is a div tag...not affected by the jQuery...
This is a div with an id...
This a blod tag...also not affected by the jQuery

This is span tag...

No comments:

Post a Comment