Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the element with no ID in jquery?

The HTML codes are like this:

<div id="select1_chzn" class="chzn-container chzn-container-single" style="width: 250px;">
     <a class="chzn-single chzn-single-with-drop"
      href="javascript:void(0)" tabindex="-1">
     <span>AFF5</span>
<div></div>
</div>

I was wondering how I could change the <span>AFF5</span> to <span>Another</span> in jquery. Does anyone have ideas about this? Thanks!

like image 787
Hanfei Sun Avatar asked Nov 23 '12 13:11

Hanfei Sun


1 Answers

Could use the id of it parent

$("#select1_chzn span").text("Another");

UPDATE

Using > means direct descendant where as a space means descendant not necessarily direct.

like image 98
AbstractChaos Avatar answered Oct 10 '22 15:10

AbstractChaos