Simplified version: I am trying to make it so the 'select' HTML attribute will call a variable value. Code:
<script src="/jquery.js"></script>
<input type="radio" id="button1" value="male">Male<br>
<div id="button2"></div>
<script>
$(document).ready(function(){
var male = 'yes';
$(document).on('click', '#button1', function() {
var value = $(this).val();
$('#button2').html(value);
});
})</script>
When the radio button is selected the div "button2" should display 'yes' (the javascript value of the variable 'male').
Do like
$(document).ready(function(){
var male = 'yes';
$(document).on('click', '#button1', function() {
var value = $(this).val();
$('#button2').html(eval(value));
});
})
Try Like
$(document).on('click', '#button1', function() {
$('#button2').html('yes');
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.