为什么我的Button的onClick()方法不能有用?
问题描述:
这里是我的html布局的一部分(用sciter框架):为什么我的Button的onClick()方法不能有用?
<div id="volume_micphone_slider" style="z-index:1;">
<input id="volume_slider" class="volume_slider" type="vslider" name="p1c" max="100" value="20" buddy="p1c-buddy" />
</div>
<div>
<button id="volume_show" class="volume_show" ></button>
<button id="micphone_show" class="micphone_show"></button>
</div>
这里是我的onClick()按钮的方法(使用tiscript):
var volume_flag=1;
function volume_ctrl()
{
if(volume_flag)
{
$(#volume_slider).style#display ="none";
volume_flag=0;
}
else
{
$(#volume_slider).style#display ="inline-block";
volume_flag=1;
}
}
$(#volume_show).onClick = function()
{
volume_ctrl();
}
但这方法不能用。请帮我弄清楚我的问题。谢谢。在你的代码
答
多的问题解释直列
var volume_flag=1;
function volume_ctrl()
{
if(volume_flag)
{
$("#volume_slider").style.display ="none"; //selector in quotes and . before style
volume_flag=0;
}
else
{
$("#volume_slider").style.display ="inline-block";
volume_flag=1;
}
}
$("#volume_show").onclick = function() //small c instead of C in onclick
{
volume_ctrl();
}
+0
最后一个'#volume_show'上的行情 – theblindprophet
+0
@theblindprophet已经完成了,在'save'后注意到了它:) – gurvinder372
答
您好尊敬它是纯粹的javascript代码
var volume_flag = 1;
function volume_ctrl() {
if (volume_flag) {
document.getElementById('volume_slider').style.display = "none";
volume_flag = 0;
} else {
document.getElementById('volume_slider').style.display = "inline-block";
volume_flag = 1;
}
}
document.getElementById('volume_show').addEventListener("click", function() {
volume_ctrl();
})
我会建议或者使用纯JavaScript或纯JQuery的。你有两个组合,这是有效的,但不一致。 – theblindprophet