<select id="users">
<option value="1">jack</option>
<option value="2">brill</option>
<option value="3">antony</option>
</select>?
Run Code Online (Sandbox Code Playgroud)
JS:
$("#users").change(function(){
alert($(this).val());
})?
Run Code Online (Sandbox Code Playgroud)
为什么在单击鼠标之前使用(keyup/keydown)时更改事件未触发
我需要为一组单选按钮注册一个处理程序.我正在使用JQuery,并希望它的.change方法能够实现这一点.但是,我没有经历过期望的行为.
这是我写的一个示例片段.遗憾的是,"radioValueChanged"仅在初始加载时调用.选择true/false不会触发处理程序.
<html>
<script src="jquery-1.4.2.min.js" type="text/javascript"></script>
<form id="myForm">
<div id="Question1Wrapper">
<div>
<input type="radio" name="controlQuestion" id="valueFalse" value="0" />
<label for="valueFalse">
False</label>
</div>
<div>
<input type="radio" name="controlQuestion" id="valueTrue" value="1" />
<label for="valueTrue">
True</label>
</div>
</div>
<div id="Question2Wrapper">
<div>
<label for="optionalTextBox">
This is only visible when the above is true</label>
<input type="text" name="optionalTextBox" id="optionalTextBox" value="" />
</div>
</div>
<script type="text/javascript">
jQuery(document).ready(function ()
{
$("#controlQuestion").change(radioValueChanged('controlQuestion'));
})
function radioValueChanged(radioName)
{
radioValue = $('input[name=' + radioName + ']:checked', '#myForm').val();
alert(radioValue);
if(radioValue == 'undefined' || …Run Code Online (Sandbox Code Playgroud) 我在我的项目中使用Jonathan Peterson的bootstrap-datetimepicker插件.
我遇到了更改事件的问题:
如果我定义这样的事件:
$('#Release').on('dp.change', function(e){ console.log(e.date()); })
Run Code Online (Sandbox Code Playgroud)
我收到错误:
未捕获的TypeError:e.date不是函数
任何人都知道如何获得更改事件的新日期值?
我正在做的事情:
我试图将子组件中的字符串传递给父组件的handleChange函数.
目前的工作原理:
我有一个父React JS类,使用以下方法:
handleChange(event) {
console.log(event.target.value);
}
Run Code Online (Sandbox Code Playgroud)
在渲染功能中,我有以下内容:
<Child handleChange={this.handleChange.bind(this)} />
Run Code Online (Sandbox Code Playgroud)
在Child课程中,我有:
<fieldset onChange={this.props.handleChange}>
<div>Tag 1: <input id="tag1" value={tags[0]} /></div>
<div>Tag 2: <input id="tag2" value={tags[1]} /></div>
<div>Tag 3: <input id="tag3" value={tags[2]} /></div>
</fieldset>
Run Code Online (Sandbox Code Playgroud)
这很好用.
我想做的是:
我试图section在handleChange函数中添加一个参数,如下所示:
handleChange(section, event) {
console.log(section);
console.log(event.target.value);
}
Run Code Online (Sandbox Code Playgroud)
在Child课程中,我有:
<fieldset onChange={this.props.handleChange("tags")}>
<div>Tag 1: <input id="tag1" value={tags[0]} /></div>
<div>Tag 2: <input id="tag2" value={tags[1]} /></div>
<div>Tag 3: <input id="tag3" value={tags[2]} /></div>
</fieldset>
Run Code Online (Sandbox Code Playgroud)
我现在得到错误:
Uncaught TypeError: Cannot read property 'target' of undefined
Run Code Online (Sandbox Code Playgroud)
我的第二个console.log语句中抛出了此错误.
我究竟做错了什么?
另外,我正在考虑使 …
我正在尝试使用最新版本的jquery.ui.spinner.js.http://wiki.jqueryui.com/w/page/12138077/Spinner
微调器正在显示和更新文本框,但我无法弄清楚如何捕获"更改"事件.当您手动更改文本框中的值时会触发它,但在使用微调器箭头时则不会触发.
jQuery的:
$('input[name*="opening"]').spinner({ min: 0, max: 100});
$('#doorsize6w7h-f').spinner().change(function(){
alert($(this).spinner('value'));
});
Run Code Online (Sandbox Code Playgroud)
HTML:
<input type="text" value="0" class="front" id="doorsize6w7h-f" name="opening[0][0]" />
Run Code Online (Sandbox Code Playgroud) 基本上,我有下拉菜单,如下所示:
<select>
<option>0</option>
<option selected="selected">1</option>
<option>2</option>
<option>3</option>
</select>
Run Code Online (Sandbox Code Playgroud)
我正在尝试编写一个即使你选择相同的选项也被触发的函数,即使打开下拉列表并重新选择所选的选项,我希望它执行该函数.
所以基本上我想计算勾选的复选框的数量.我得到的代码到了成功计算它的位置,但是我想要显示一个警告,显示勾选的复选框的数量,代码执行此操作但不显示总计数,它会增加每次刷新的总数.我只想知道如何显示总数.
单击单选按钮"是"时,应显示总计.
<br />Apples
<input type="checkbox" name="fruit" />Oranges
<input type="checkbox" name="fruit" />Mango
<input type="checkbox" name="fruit" />
<br />Yes
<input type="radio" name="yesorno" id="yes" onchange="checkboxes()"
Run Code Online (Sandbox Code Playgroud)
function checkboxes(){
var inputElems = document.getElementsByTagName("input"),
count = 0;
for (var i=0; i<inputElems.length; i++) {
if (inputElems[i].type === "checkbox" && inputElems[i].checked === true){
count++;
alert(count);
}
}}
Run Code Online (Sandbox Code Playgroud) 我的系统中有两个微调器.现在我必须根据第一个微调器值更改第二个微调器的选定值.一旦用户更改第一个微调器值,第二个微调器值将根据第一个微调器的选定值自动设置.怎么实现这个?
我的更改功能允许用户从一个国家切换到另一个国家,并获得不同的文本和功能.它在更改国家/地区选择时有效.但是在初始页面加载时,它不会触发jQuery更改来设置隐藏和显示默认/初始国家/地区的文本div.
两个div都显示在初始页面加载时.当我改变然后回到默认/初始国家时,更改火灾,隐藏和显示火灾,并显示正确的信息和功能.
我已尝试document.ready在开关选择内部和更改功能外部使用更改功能.两者都没有工作 - 他们不会在doc准备好的交换机案例中激活hide,show和其他jQuery.我不清楚'ready'是否是一个有效的触发事件.
我也尝试过:
$('input[name=country]').value('US').trigger('click');
Run Code Online (Sandbox Code Playgroud)
但它打破了改变功能.这是代码.下面的国家选择只是2个国家,以保持简单,但实际上,有很多.
$(document).ready(function()
{
//1st tier - select country via radio buttons:
//Initialize country
$('input[name=country]:first').attr('checked', true); //Set first radio button (United States)
//$('input[name=country]:first').attr('checked', true).trigger('ready'); //sets 1st button, but does not fire change
//$('input[name=country]:first').trigger('click'); //sets 1st button, but does not fire change
$('input[name=country]').change(function ()
{
// change user instructions to be country specific
switch ($('input[name=country]:checked').val())
{
case 'US':
$('#stateMessage1').text('2. Select a state or territory of the United States.');
$('#stateMessage2').text('Start typing a state of …Run Code Online (Sandbox Code Playgroud) 是可能的事件来检测onChange用于<input type=“date”>,当用户使用图形日历和箭头或使用 keybord数目?
我只对VanillaJS解决方案感兴趣.
onchange ×10
jquery ×6
javascript ×3
html ×2
spinner ×2
android ×1
checkbox ×1
events ×1
forms ×1
html5 ×1
radio-button ×1
radio-group ×1
reactjs ×1