내 마지막 질문은 여기에 : Get last clicked item id 좋은 답변이 있었지만 여전히 문제가 있습니다.jQuery - 첫 번째 항목을 버블 링합니다.
이 같은 기능을 가지고 :
$(document).ready(function() {
$("*").click(function() {
alert($(this).attr('id').toString());
});
});
그리고 페이지
내가 이런 걸 가지고<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<script language="javascript" src="Scripts/jquery-1.4.1.js" type="text/javascript"><script>
<div id="div1">Some stuff
<div id="div2">Some other stuff
<asp:Button ID="Button1" runat="server" Text="Button" />
<div id="div3">More stuff
<asp:Button ID="Button2" runat="server" Text="Button" />
</div>
</div>
Alertbox 내가 이런 클릭 항목의 값을 저장할 수 나타나면 :
$(document).ready(function() {
$("*").click(function (e) {
alert($(this).attr('id').toString());
var value = $(this).attr('id').toString();
e.stopPropagation(); //Stop Propagation
});
});
하지만 여기에 문제가 있습니다. 전파를 멈 추면 다른 스크립트는 더 이상 작동하지 않습니다. 어떻게 거품 순서 나 ID를 얻을 수 있습니까? 나는이 같은 일이
$(document).ready(function() {
$("*").click(function (e) {
if(e.target == this[0])
{
alert($(this).attr('id').toString());
var value = $(this)[0].attr('id').toString();
}
//e.stopPropagation(); //I have to get first value from bubbling without stopPropagation
});
});
감사? : 할 수있다!
괄호없이. 'if (ev.target === this) {' –