Reputation: 848
I got this double drop down list
<div class="container" id = "chooseTables">
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown">please choose tables <span class="caret"></span></button>
<ul class="dropdown-menu">
<li class="dropdown-submenu">
<a class="test" tabindex="-1" href="#">table for 2<span class="caret"></span></a>
<ul class="dropdown-menu">
<li class = "select" id = "table1" ><a tabindex="-1" href="#"><align = "middle">-----table1-----</a></li>
<li class = "select" id = "table2" ><a tabindex="-1" href="#"><align = "middle">-----table2-----</a></li>
<li class = "select" id = "table3" ><a tabindex="-1" href="#"><align = "middle">-----table3-----</a></li>
</ul>
</li>
</ul>
</div>
</div>
Every time the server send me some info I want to update text content in those <li>
tags.
ie.
var room = document.getElementsByClassName("select")
room[1].textContent = "vacant"
But I could not change only the text without affecting its attributes like align
and href
I tried textContent
and childNodes[0].nodeValue
they did not really work.
Here is fiddle:http://jsfiddle.net/TU4FB/135/
Upvotes: 0
Views: 55
Reputation: 100
room[1].getElementsByTagName('a')[0].textContent = "11"
or
room[1].getElementsByTagName('a')[0].getElementsByTagName('align')[0].textContent = "11"
Upvotes: 2