Thursday, July 8, 2010

jQuery, id Selector

You create an id for one or more HTML tags and with jQuery you can manipulate it.

Syntax:
$('#idName').css(propertyName', 'propertyValue');

See the example below.









<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(){
$('#box').css('background','yellow')
.css('border','solid 16px green')

})
</script>
</head>

<body>
<div id='box'>This is a div tag with box id.</div>
<div id='notbox'>This is a div tag with notbox id.</div>

</body>
</html>







This is a div tag with box id.
This is a div tag with notbox id.

No comments:

Post a Comment