Hi,
In my code below, I'm looking to select the title attribute when a button is clicked...but it doesn't seem to work...could anybody help me with this please?
Code:
<html>
<head>
<title></title>
<script src="http://code.jquery.com/jquery-1.6.2.min.js"></script>
<style type="text/css" title="content1">
body {
background: #ccc;
color: #aaa;
font: 12px courier new;
line-height: 20px;
}
button {
background: #f1f1f1;
border: 1px solid #aaa;
color: #aaa;
font: bold 11px arial;
padding: 10px;
}
</style>
<style type="text/css" title="content2">
body {
background: #f1f1f1;
color: #aaa;
font: 12px arial;
line-height: 20px;
}
#wrap {
background: #fff;
border: 1px solid #ccc;
margin: auto;
padding: 10px;
}
</style>
<script>
$(document).ready( function(){
$("button").click( function() {
alert("you've clicked me!");
if($('style').attr("title")=="content1") {
$('style').attr("title", "content2");
};
});
});
</script>
</head>
<body>
<div id="wrap">
<button>Click me!</button>
</div>
</body>
</html>