小编Z.Z*_*don的帖子

javascript单击下拉列表中的值

我有以下用HTML编写的代码:

    <table cellspacing="0" cellpadding="0" width="100%" class="HeaderTable">
    <tbody><tr>
        <td id="dnn_ctr6707_TimeTableView_TdClassesList" class="HeaderClassesCell">
            class
            <select name="dnn$ctr6707$TimeTableView$ClassesList" onchange="javascript:setTimeout(&#39;__doPostBack(\&#39;dnn$ctr6707$TimeTableView$ClassesList\&#39;,\&#39;\&#39;)&#39;, 0)" id="dnn_ctr6707_TimeTableView_ClassesList" class="HeaderClasses">
            <option selected="selected" value="14">a</option>
            <option value="15">b</option>
            <option value="16">c</option>
            <option value="17">d</option>
            <option value="49">e</option>
            <option value="60">f</option>
        </select></td>
Run Code Online (Sandbox Code Playgroud)

我正在尝试做的是,在控制台选项卡中单击选项'b'.出于某种原因,它对我来说不起作用,但我觉得这似乎很好.

这是我试过的:

var x = document.getElementById('dnn_ctr6707_TimeTableView_ClassesList') // this part work
var y = x.options[1].click() // I managed to get the text of the option but I want it to perform click and it doesn't work that way :(
Run Code Online (Sandbox Code Playgroud)

谢谢您的帮助!

javascript

3
推荐指数
1
解决办法
1778
查看次数

检查骑士在两点之间的移动是否有效

我正在用C++做一个国际象棋项目.我正在尝试检查2D阵列中的有效骑士移动.

我有玩家this->getLocX(),this->getLocY()变量的旧位置(玩家所在的位置)和我有x,y(这是玩家想要将他的骑士移入的地方).

如何以最佳方式检查有效性?这是我的解决方案,但我想知道是否有更好的方法.

if (x == this->getLocX() + 1 && y == this->getLocY() + 2 || x == this->getLocX() - 1 && y == this->getLocY() + 2 || y == this->getLocY() + 1 && x == this->getLocX() + 2 || y == this->getLocY() + 1 && x == this->getLocX() - 2  || x == this->getLocX() - 1 && y == this->getLocY() + 2 || x == this->getLocX() + 1 && y == this->getLocY() - 2 || …
Run Code Online (Sandbox Code Playgroud)

c++ algorithm chess

0
推荐指数
1
解决办法
189
查看次数

标签 统计

algorithm ×1

c++ ×1

chess ×1

javascript ×1