如何将此代码放入一个 div 类 .element 中?
var side_bar_html = "<a href='javascript:google.maps.event.trigger(gmarkers[" + parseInt(gmarkers.length - 1) + "],\"click\");'>" + place.name + "</a><br>" + '<div class="raty" />' + "</br>";
$(side_bar_html).appendTo('#side_bar').filter('.raty').raty({
score : place.rating,
path : 'http://wbotelhos.com/raty/lib/img'
})
此代码呈现 HTML:
<a href='javascript:google.maps.event.trigger(gmarkers[0],"click");'>The Fort</a>
<br>
<div class="raty" style="cursor: pointer; width: 100px;"><img src="http://wbotelhos.com/raty/lib/img/star-on.png" alt="1" title="bad"> <img src="http://wbotelhos.com/raty/lib/img/star-on.png" alt="2" title="poor"> <img src="http://wbotelhos.com/raty/lib/img/star-on.png" alt="3" title="regular"> <img src="http://wbotelhos.com/raty/lib/img/star-on.png" alt="4" title="good"> <img src="http://wbotelhos.com/raty/lib/img/star-half.png" alt="5" title="gorgeous"><input type="hidden" name="score" value="4.5"></div>
我想将所有这些代码放入 DIV 类 .elemenat
怎么做?
我需要为此编写一个函数吗?