I've started coding a chat application with PHP
, jQuery
and HTML5
. I have got in a little trouble.
When I send a message, it appends [x]
every time before the name even if there is an [x]
or not already.
A piece of HTML codes:
<table id="mt" border="0" style="width:100%">
<tr id="-1" class="list-group" style="box-shadow:none;margin-bottom:0;">
<td class="list-group-item" style="border-radius:0;border:none;border-bottom:1px solid #DDD">
<h4 class="list-group-item-heading text-center">Example Sticky Message</h4>
<p class="list-group-item-text text-center">
You may add your announcements and requests here. You may edit here in the admin panel.
</p>
</td>
</tr>
<tr id="10" class="list-group" style="box-shadow:none;margin-bottom:0;">
<td class="list-group-item nth" style="border-radius:0;border:none;border-bottom:1px solid #DDD">
<div class="list-group-item-text">
<div class="postedIn">21/01/16 12:04 AM</div>
<a href="javascript:;" id="dm" onclick="delmess($(this).closest('tr').attr('id'))">[x]</a> <b class="usr mem_admin">Admin</b>:
Bu mesaj örnek bir gönderidir. Mesaj Admin tarafından yollanmıştır.
</div>
</td>
</tr>
<tr id="9" class="list-group" style="box-shadow:none;margin-bottom:0;">
<td class="list-group-item nth" style="border-radius:0;border:none;border-bottom:1px solid #DDD">
<div class="list-group-item-text">
<div class="postedIn">21/01/16 12:04 AM</div>
<a href="javascript:;" id="dm" onclick="delmess($(this).closest('tr').attr('id'))">[x]</a><a href="javascript:;" id="dm" onclick="delmess($(this).closest('tr').attr('id'))">[x]</a> <b class="usr mem_admin">Admin</b>:
Bu mesaj örnek bir gönderidir. Mesaj Admin tarafından yollanmıştır.
</div>
</td>
</tr>
</table>
I want my JS code to check if there is an [x]
before the name. If not, add [x]
there; if there is, pass it and continue for all the other with b
tags.
Thanks in advance!
Did you try with a class for the x
mark? You can add that class to every div you add (or any other tag u use) and then style it with css.
It's quite difficult to answer while not having a minimum piece of HTML code.
Edit1: it's recommended NOT to use the <b></b>
tag. In HTML5 you have <strong></strong>
. This does the same thing, but it marks it as important and on the settings, some browsers might "pronounce it" (i.e. for any person who has poor eye sight).