2012-03-07 7 views
0

私は500 x 500pxのdivを持っているとしましょう。その中には<input type="file" />、それも500 x 500、不透明度は0です。テキスト入力がファイル入力の上にあるときにクリックイベントを制限する方法

私のdivの中には、目に見えないものの上に別のテキストまたはテキストエリアの入力があります。今度は、親のトップインプットの中をクリックするたびに、ファイルチューザが表示されます(インビジブルファイルの下に入力されています)。

クリックイベントをキャプチャして一番上の入力で停止する方法はありますか?私はトップのテキスト入力を処理するときにファイルの選択が表示されないようにしたい。

Sample Here。 JavaScriptを使用して

+0

は私たちに例や、少なくともコードを入力してください。あなたが何を意味するかは分かりません。 – Alex

+0

この問題を示す[jsfiddle](http://jsfiddle.net/twashing/hdqUd/1/)があります。 – Nutritioustim

答えて

1

<html> 
<head> 
    <script type="text/JavaScript"> 
     function doSomething(event) 
     { 
      // use these functions to stop the event here 
      // different browsers may or may not have the function, so check to make sure it exists before calling it. 
      if (event.cancelBubble) 
       event.cancelBubble(); 
      if (event.stopPropagation) 
       event.stopPropagation(); 
     } 
    </script> 
</head> 
<body> 
    <div onclick="alert('this will not show when you click on the text input');"> 
     <input type="text" onclick="doSomething(event)" /> 
    </div> 
</body> 
</html> 
+0

甘い。それがトリックでした。ありがとう。 – Nutritioustim

関連する問題