スパンをクリックするたびに、imgタグまたはタグのどちらを含むかを検出したいと思います。これどうやってするの。
<span class="scorecount" id="6" onclick="javascript:changethevalue(this)">
<img src="images/lock.png" width="25px" height="25px">
</span>
<span class="scorecount" id="6" onclick="javascript:changethevalue(this)">
4
</span>
function changethevalue(object) {
console.log($(object).children('img'));
}
出力は私がimgをクリックしたときです
[img、prevObject:jQuery.fn.jQuery.init [1]、コンテキスト:span#4.scorecount、セレクター: "img"、コンストラクター:関数、init:関数…]
4では、[prevObject:jQuery.fn.jQuery.init [1]、コンテキスト:span#2.scorecount、セレクター: "img"、コンストラクター:function、init:function…]です。