Created
May 20, 2011 09:09
-
-
Save k4200/982600 to your computer and use it in GitHub Desktop.
attr and prop in jQuery 1.6.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<script src="jquery-1.6.1.js"></script> | |
<script type="text/javascript"> | |
function test() { | |
//FF4で確認。他のブラウザも要チェック | |
console.log($("#div1")); | |
console.log($("#div1").prop("val")); //NG | |
console.log($("#div1").attr("val")); //OK | |
console.log($("#div1")[0].getAttribute("val")); //OK | |
console.log($("#div2")); | |
console.log($("#div2").prop("value")); //NG | |
console.log($("#div2").attr("value")); //NG | |
console.log($("#div2")[0].getAttribute("value")); //OK | |
} | |
</script> | |
<body> | |
<div id="div1" val="one">one un aaa</div> | |
<div id="div2" value="two">two deux bbb</div> | |
<input type="button" onclick="test();" /> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment