phpjavascriptwebjqueryhtml5
There are 4 reviews. When you click on one review and add the category on, the others will not be clicked and will only prompt you that you have reviewed it~ I have been working on it for a long time~ Please give me some guidance (my current approach will be given to everyone liAdd on! So annoying)
Have you ever thought about what would happen if you clicked wrongly? . Which one should you click to add on, and then remove the on style of other li at the same time? If you are sure you want to click, it will not be modified. You must first determine whether there is an on item in the li, and if you click on something that does not already exist, it will prompt
<code> <style>li.on{color:green}</style> <ul id="ul"> <li>很满意</li> <li>满意</li> <li>一般</li> <li>差</li> </ul> <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.2.min.js"></script> <script> $('#ul li').click(function () { if (!$(this).hasClass('on') && $(this).siblings().hasClass('on')) alert('你已经评价'); else this.className='on' }); </script> </code>
Single choice. Just make a single choice.
Yes, as mentioned on the first floor, you can dynamically add a class, and then click on it to have this class, but not others, you can judge it