如何从表中调用按钮?

时间:2017-11-03 07:20:36

标签: javascript button webpage

我正在制作一个网页的快捷键,当按下我的ESC键而不必鼠标按下并单击它时,单击按钮。我似乎无法让它发挥作用。

document.getElementsByTagName('idOrderOpenTable').openMarketOrdersTable[1].click();

button

3 个答案:

答案 0 :(得分:1)

您使用sid::Members方法接收<table id="idOrderOpenTable"></table>的孩子,但您应该使用document.getElementsByTagName。 例如:

document.querySelector

答案 1 :(得分:0)

您可以尝试此示例并根据需要进行修改,

&#13;
&#13;
function keydownFunction(e) {
	if (e.keyCode === 27){
    document.getElementById("button").click();
    }
}
&#13;
<!DOCTYPE html>
<html>
<body onkeydown="keydownFunction(event)">

<div >Test <input type="button" value="Button" id="button" onclick="alert('Hello');"/></div>

</body>
</html>
&#13;
&#13;
&#13;

脚本查找按下的esc键并调用按钮的单击。

答案 2 :(得分:0)

要在表格中找到您的按钮,请使用querySelector()。它返回与您的查询匹配的第一个元素。

&#13;
&#13;
var Feed = require('rss-to-json');

Feed.load('https://codek.tv/feed/', function(err, rss){
   console.log(rss);
});
&#13;
var RSSCombiner = require('rss-combiner');
var Feed = require('rss-to-json');

var feedConfig = {
  title: 'Tech news from Guardian and BBC',
  size: 20,
  feeds: [
    'http://feeds.bbci.co.uk/news/technology/rss.xml',
    'https://www.theguardian.com/uk/technology/rss'
  ],
  pubDate: new Date()
};

// combine feeds
RSSCombiner(feedConfig)
.then(function (combinedFeed) {
  var xml = combinedFeed.xml();

  // convert combined feed to json
  Feed.load(xml, function(err, rss){ 
    console.log(rss);
  });
});
&#13;
&#13;
&#13;