我想寫一些JavaScript,當用戶點擊各自的文本時,將返回toasty.png和bready.png的值。我能夠返回「吐司」和「麪包」,但不能包含其他文本。有什麼建議?如何在javascript中將值返回給控制檯?
<script>
$(document).on('vclick', '.changePageButton', function() {
console.log(this.text);
//console.log(value within the image)
});
</script>
<a class="changePageButton" value="Toast" data-transition="slide">
<input type = "hidden" name = "image" value = "toasty.png">
<input type = "hidden" name = "video" value = "video1.mpg">
test
</a>
<a class="changePageButton" value="bread" data-transition="slide">
<input type = "hidden" name = "image" value = "bready.png">
<input type = "hidden" name = "video" value = "video2.mpg">
test
</a>
如果我有內部的多個隱藏輸入字段標籤? – sharataka
然後你可以使用'.get(x)'選擇其中的一個,或者你可以在'.children()'參數中更具體。 –
我剛纔編輯了我的代碼。我如何更具體地使用.children? – sharataka