Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/398.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在jquery中单击一个单击另一个的东西?_Javascript_Jquery - Fatal编程技术网

Javascript 如何在jquery中单击一个单击另一个的东西?

Javascript 如何在jquery中单击一个单击另一个的东西?,javascript,jquery,Javascript,Jquery,我正在尝试设置一点javascript来检测何时单击事件的标题以及何时单击另一个链接(如果有意义的话) 刚刚意识到它必须点击事件卡本身中的链接 这是我的代码: var eventTitle = $(".eventCardCnt .title"); var eventMoreInfo = $(".custom_button").find("a"); eventTitle.click( function(){ eventMoreInfo.trigger("click");

我正在尝试设置一点javascript来检测何时单击事件的标题以及何时单击另一个链接(如果有意义的话)

刚刚意识到它必须点击事件卡本身中的链接

这是我的代码:

var eventTitle = $(".eventCardCnt .title");
var eventMoreInfo = $(".custom_button").find("a");

    eventTitle.click( function(){
       eventMoreInfo.trigger("click");
        //console.log("title clicked");
    });
html:

        <div class="eventCardCnt eventDisplayCnt  isAnEvent" >
        <div class="cntHolder" >
        <div class="details">
        //  When this is clicked.
        <span class="title">Understanding ‘Prevent Duty’ & Radicalisation</span>
        <div class="dateDetails" style="color:#999999; font-size:14px; line-height:120%;font-weight:normal; padding:3px 0px; padding-bottom:0px;text-align:left; margin-bottom:5px; margin-top:0px; border-bottom:0px solid #EEEEEE;">
        <div class="dateCnt">
        <div class="dates">
        <div class="dateWrap">
        <div class="date">Wednesday 10 February 2016</div>
        <div class="time">9:30 am</div>
        </div>
        </div>
        </div>
        </div>
        <span class="location"><a href="http://maps.google.com/?q=Holiday+Inn,+Camden+Lock,+London" target="_blank">Holiday Inn, Camden Lock, London</a></span>
        <div class="eventDetails">
        <div class="price" >£250.00</div>
        <div class='custom_button'>
        <div class="more_info_button">
        //  Click this link
        <a href="http://carleyconsult.wp.castus1.co.uk/product/understanding-prevent-duty-radicalisation/">More info and book</a>
        </div>
        </div>
        </div>
        </div>
        </div>
        </div>

//单击此按钮时。
理解“预防责任”和激进化
2016年2月10日星期三
上午9:30
£250.00
//单击此链接

任何想法都将不胜感激。

您可以在标题单击事件中使用单击事件,如$(“.link”)。单击()

$(".header").click(function(){
    $(".link").click();
});
$(".link").click(function(){
    alert("Another link Clicked");
});
试试这个代码 HTML页面

<div class="eventCardCnt eventDisplayCnt  isAnEvent" >
        <div class="cntHolder" >
        <div class="details">
        //  When this is clicked.
        <span class="title" onclick="clickhref()" >Understanding ‘Prevent Duty’ & Radicalisation</span>
        <div class="dateDetails" style="color:#999999; font-size:14px; line-height:120%;font-weight:normal; padding:3px 0px; padding-bottom:0px;text-align:left; margin-bottom:5px; margin-top:0px; border-bottom:0px solid #EEEEEE;">
        <div class="dateCnt">
        <div class="dates">
        <div class="dateWrap">
        <div class="date">Wednesday 10 February 2016</div>
        <div class="time">9:30 am</div>
        </div>
        </div>
        </div>
        </div>
        <span class="location"><a href="http://maps.google.com/?q=Holiday+Inn,+Camden+Lock,+London" target="_blank">Holiday Inn, Camden Lock, London</a></span>
        <div class="eventDetails">
        <div class="price" >£250.00</div>
        <div class='custom_button'>
        <div class="more_info_button">
        //  Click this link
        <a id="aclick" href="http://carleyconsult.wp.castus1.co.uk/product/understanding-prevent-duty-radicalisation/">More info and book</a>
        </div>
        </div>
        </div>
        </div>
        </div>
        </div>

为什么图片中有html代码?用真实的代码而不是源代码的图像来解决你的问题。。在问题中共享html检查我制作的示例希望这对您有效我想您需要:
$(此)。查找('.custom_按钮a')[0]。单击()干杯@A.Wolff施展魅力:)
function clickhref()
{
     $("#aclick").click();
}