Div' Inside 'Table'

div' inside 'table'

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>test</title>
</head>
<body>
<table>
<tr>
<td>
<div>content</div>
</td>
</tr>
</table>
</body>
</html>

This document was successfully checked as XHTML 1.0 Transitional!

Access contents of div inside table cell

Use

$(check).closest(".task-modal-row").find(".task_description").text();

To access the content of the closest .task_description

How to set 100% height of div inside table cell

Demo - codepen

Here's another relevant SO answer

It appears you need to add a height to the <table> tag.

<table style="border-collapse: collapse; height:100%">

How can i apply css for div inside table?

You can do something like this:

table.new td div{
color:red;
}

It will change the css of Div inside a td tag.

XPath how to select specific div inside of table row

I was able to solve it by using:

//td/div[text()='test1']/ancestor::tr/td/div[@class='custom' and text()='Failed']

How to correctly select a div inside a table cell

I made some changes in your code. Removed deleteRow binded on table and add event only on div element, then find parent row element and removed it from table
Does this help you?

function createNewTableElement() {

var inputField = document.getElementById("new-item");

if (inputField.value == "") {

return;

}

var row = document.createElement("tr");

var cell = document.createElement("td");

var div = document.createElement("div");

div.onclick = deleteRow;

var cellText = document.createTextNode(inputField.value);

cell.appendChild(div);

cell.appendChild(cellText);

row.appendChild(cell);

obj = document.getElementById("main-table");

obj.appendChild(row);

}

function deleteRow(e) {

document.getElementById('main-table').removeChild(e.target.parentElement.parentElement);

}
#main-table div {

height: 10px;

width: 10px;

border: 1px solid;

display: inline-block;

margin-right: 10px;

}
<button class="btn" onclick="createNewTableElement()">Add</button>

<input id="new-item" type="text" value="item">

<table id="main-table">


Related Topics



Leave a reply



Submit