|
|
|
อยากทำให้ radio button มันทำงานตอนโหลดหน้าเลยอ่ะครับ มีวิธีมั้ยครับ |
|
|
|
|
|
|
|
Code (JavaScript)
<!doctype html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
alert($("#x:checked").val());
});
</script>
</head>
<body>
<form id="myForm">
<input type="radio" name="myRadio" id="x" value="1" checked /> 1 <br />
<input type="radio" name="myRadio" id="x" value="2" /> 2 <br />
<input type="radio" name="myRadio" id="x" value="3" /> 3 <br />
</form>
</body>
</html>
|
|
|
|
|
Date :
2014-12-25 16:16:06 |
By :
tam78910 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<script>
$(document).ready(function () {
//$('#div1').hide();
$('#myForm input').on('change', function() {
alert($('input[name="myRadio"]:checked', '#myForm').val());
}).change();
});
</script>
</head>
<body>
<form id="myForm">
<input type="radio" name="myRadio" value="1" /> 1 <br />
<input type="radio" name="myRadio" value="2" /> 2 <br />
<input type="radio" name="myRadio" value="3" /> 3 <br />
</form>
</body>
รับทำโปรเจค
|
|
|
|
|
Date :
2014-12-26 09:24:53 |
By :
pjgunner.com |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
html5
checked="checked"
เขาใช้ checked ได้เลย
มันไม่ใช่ html4 หรือ xhtml
|
|
|
|
|
Date :
2014-12-26 10:26:28 |
By :
fossil31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|