Using jQuery, how to check if a table cell is empty or not?
Please help me.
What do you mean by empty.
//cell maycontain new lines,spaces,&npsp;,... but no real text or other element $("cellselector").text().trim()=="";
or
//cell has no child elements at all not even text e.g. <td></td> $("cellselector:empty")
You can use the CSS selector with a function $to get a reference to a cell element, and then use htmlto find out if it has any content. For example, if the cell has the identifier "foo":
$
html
if ($("#foo").html()) { // The cell has stuff in it } else { // The cell is empty }
:
$content = $('#your_cell_id_here').html(); if($content == '') { // yes it is empty } else { // no it is not empty }
css table , jquery, :
table
if ( !($('#mytable tr.row-i td.column-j').html()) ) { alert("empty"); }
, .
http://www.keithrull.com/2010/06/09/HowToChangeTableCellColorDependingOnItsValueUsingJQuery.aspx
You can use this if you already know the identifier of the cell you want to check.
$valueOfCell = $('#yourcellid').html();
or you can iterate over table cells
$("#yourtablename tr:not(:first)").each(function() { //get the value of the table cell located //in the third column of the current row var valueOfCell = $(this).find("td:nth-child(3)").html(); //check if its greater than zero if (valueOfCell == ''){ //place action here } else{ //place action here }
});
Source: https://habr.com/ru/post/1726334/More articles:https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1726329/how-can-i-configure-my-windows-service-in-the-code-to-access-the-desktop&usg=ALkJrhg4vqLOrZzT3pasiIKeNIAQ4Sx6swWhat is the point of providing an MD5 or SHA1 hash along with a downloadable executable? - securityTwo-dimensional ball collisions with corners - simulationShould a class with a Thread element implement IDisposable? - multithreadingconverting python based on zcml script to standalone script in zope / plone - pythonВызов удаленного процесса без общей файловой системы - erlangHow many weeks are inside two dates - dateHow to use DATEDIFF? How many days are inside two dates - databaseHow to set up the environment to use JavaMail? - javaAccess to elements of the child user interface in the Qt interface - qtAll Articles