gpt4 book ai didi

javascript - jQuery Click 事件不会在元素单击时触发

转载 作者:行者123 更新时间:2023-11-30 21:13:25 24 4
gpt4 key购买 nike

<分区>

下面是我的 html 和 javascript。 Js 位于 app.js 文件中,html 是一个是或否的问题。在 javascript 的底部,我有应该在点击事件时触发的代码。现在只是看看它是否检测到对 html 中 p 元素的点击,但到目前为止还没有成功。

任何人都可以检测为什么没有发生此事件吗?

其他 jQuery int 他的代码确实有效,但这个 jQuery 不是由函数调用的,而是严格使用选择器调用的,这让我相信我在我的项目中使用 document.ready 的方式有问题。

HTML:

 <div class="question animated slideInUp">

<h3>Do you know your individual monthly rent cost?</h3>

<div class="rentanswer">
<p>Yes</p><p>No</p>
</div>
<!--
<p>If not, we'll get the average rent of a zip code for you from Zillow</p>
<form onsubmit="Obj(this.p.name,this.p.value)">
<input type="number" id="p" name="rent" placeholder="Leave blank if N/A" >
<input id="s" type="submit" value="Submit">
</form>
-->

</div>

Javascript:

 var quest = ['../partials/income.hbs', '../partials/state.hbs', '../partials/rent.hbs', '../partials/zip.hbs', '../partials/roomate.hbs', "../partials/summary.hbs"];
var iterator = 0;
//creates object that gets sent to api
function Obj(name, vale){

event.preventDefault(); //prevents pg refresh

$('.form').load(quest[iterator], function () {
$('.bar p#' + name).css("border","2px solid black").addClass('enter').next().css({"border":"2px solid black","pointer-events":"auto","cursor":"pointer"});
});
//loads next html question to page
if(name){

data[name] = vale;
}
//move array accessor up to next question
iterator++;

console.log(data);
}
var data = {};


//user can click already submitted values to load that orignal question and change it/
function redo(q, id) {
q = Number(q);
//if the current queston on the page is not the one being clicked we then change it to the one being clicked
if (q + 1 != iterator) {
$('.form').load(quest[q], function () {


$('#p').val(data[id]);
});
iterator = q + 1;
};
};

$(document).ready(function(){
$('.rentanswer p').on('click',function(){
console.log('hey');
});
});

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com