2016-04-28 200 views
0

這裏是我的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(); 
} 

但這方法不能用。請幫我弄清楚我的問題。謝謝。在你的代碼

+0

我會建議或者使用純JavaScript或純JQuery的。你有兩個組合,這是有效的,但不一致。 – theblindprophet

回答

0

多的問題解釋直列

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

-1

您好尊敬它是純粹的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(); 
     }) 
相關問題