如何使用jQuery或Javascript触发鼠标点击部分元素?

时间:2015-10-09 06:37:52

标签: javascript jquery

 <td class="GNEB1S-HKB" valign="middle">
     <div style="white-space: normal;line-height:1.2;font-size:10px;width:100px; color:#969696;" id="DOM_110">
           <div title="15 of 212 items were loaded. Click to load all items.">212 found<br>
                 <span style="text-decoration:underline;cursor:pointer" onclick="return handleEvent(event,'com.polarion.alm.tracker.web.js.internal.TrackerNew68/com.polarion.reina.web.js.widgets.HTMLComposite69/com.polarion.reina.web.js.widgets.HTMLContainer70/com.polarion.alm.tracker.web.js.internal.trackercards.TrackerCardTree71/com.polarion.alm.tracker.web.js.internal.trackercards.TrackerCardTree$3375/com.polarion.reina.web.js.widgets.HTMLComposite376/com.polarion.reina.web.js.widgets.HTMLContainer377/com.polarion.reina.web.js.widgets.HTMLSplitPane382/com.polarion.reina.web.js.widgets.HTMLSplitPane378/com.polarion.alm.tracker.web.js.internal.treetable.TrackerTreeAndQP225/com.polarion.reina.web.js.widgets.HTMLComposite227/com.polarion.alm.tracker.web.js.internal.treetable.TrackerTree217','click1913',false)">Load all</span>
         </div>
     </div>
 </td>

对于网页,我将上述内容作为元素。元素加载所有末尾的文本为 Clickable 。使用JQuery或JavaScript我想点击那个全部加载。

如何做到这一点?

2 个答案:

答案 0 :(得分:0)

嗯...在javascript中你应该这样做...... 但我不知道你的'handleEvent'功能是做什么的...... 无论如何......这是代码

 <td class="GNEB1S-HKB" valign="middle">
     <div style="white-space: normal;line-height:1.2;font-size:10px;width:100px; color:#969696;" id="DOM_110">
           <div title="15 of 212 items were loaded. Click to load all items.">212 found<br>
                 <span id="loader" style="text-decoration:underline;cursor:pointer" onclick="return handleEvent(event,'com.polarion.alm.tracker.web.js.internal.TrackerNew68/com.polarion.reina.web.js.widgets.HTMLComposite69/com.polarion.reina.web.js.widgets.HTMLContainer70/com.polarion.alm.tracker.web.js.internal.trackercards.TrackerCardTree71/com.polarion.alm.tracker.web.js.internal.trackercards.TrackerCardTree$3375/com.polarion.reina.web.js.widgets.HTMLComposite376/com.polarion.reina.web.js.widgets.HTMLContainer377/com.polarion.reina.web.js.widgets.HTMLSplitPane382/com.polarion.reina.web.js.widgets.HTMLSplitPane378/com.polarion.alm.tracker.web.js.internal.treetable.TrackerTreeAndQP225/com.polarion.reina.web.js.widgets.HTMLComposite227/com.polarion.alm.tracker.web.js.internal.treetable.TrackerTree217','click1913',false)">Load all</span>
         </div>
     </div>
 </td>

<script>
var myspan=document.getElementById("loader");
myspan.click();
</script>

答案 1 :(得分:0)

你可以这样做:

 <span class="loader-class">....</span>

在jQuery中:

 $(".GNEB1S-HKB span").trigger("click", function(evnt){
        //handle the click if needed here
        console.log("I have been clicked!!");
 });

如果您可以设法将一个类添加到span元素,就像这样,

 $(".loader-class").trigger("click", function(evnt){
        //handle the click if needed here
        console.log("I have been clicked!!");
 });