JS Bootstrap从下拉列表获取curent文本(无需操作)

时间:2015-09-14 21:16:27

标签: javascript twitter-bootstrap drop-down-menu

我正在尝试从下拉列表中获取当前文本:

function dtChange(){
  var elem = document.getElementsByName("ul.dropdown-menu li a");
  var name = elem.innerHTML;

但名称始终为“未定义”:

<div class="dropdown" name="dpt1">
    <button class="btn btn-default dropdown-toggle" type="button" id="menu1" data-toggle="dropdown" data-target="#">ATT
    <span class="caret"></span></button>
    <ul class="dropdown-menu" id="company" role="menu" aria-labelledby="menu1">

怎么了?请帮忙。

1 个答案:

答案 0 :(得分:0)

&#13;
&#13;
df[df == 0] <- NA
sapply(df, function(x)all(is.na(x)))
&#13;
&#13;
&#13;

&#13;
&#13;
function dtChange(){
  var elem = document.getElementsByName(".dropdown-menu li a");
  var name = elem.innerHTML;
&#13;
&#13;
&#13;

希望能帮到你