Following are the html tips:
Change the menu
function showHide(anchor)
{
if(anchor.innerHTML.startsWith("Show"))
{
anchor.innerHTML = anchor.innerHTML.replace("Show","Hide");
}
else
{
anchor.innerHTML = anchor.innerHTML.replace("Hide","Show");
}
}
Checking if the div with id exists
ength property will return zero if element does not exists.
if ($("#mydiv").length > 0){
// do something here
}
Getting the child element from the parent element
var parent = document.getElementById('disptable');
parent.querySelector("#boardc");
Setting CSS to the element
function setCSS(eleID) {
var currTabElem = document.getElementById(eleID);
currTabElem.setAttribute("class", "some_class_name");
currTabElem.setAttribute("className", "some_class_name");
}
Show and Hide div element
`Click Me
This is my DIV element.
function myFunction() {
var x = document.getElementById("myDIV");
if (x.style.display === "none") {
x.style.display = "block";
} else {
x.style.display = "none";
}
}`
Creating Text Node
let docs = document.getElementByID('#freelancer');
let elements = freelancer.getElementsByClassName('item');
var td1 = document.getElementById('td1');
var text = document.createTextNode("some text");
td1.appendChild(text);
removing the highlighted marked text
targets = document.querySelectorAll("mark");
for (let target of targets) {
target.outerHTML=target.innerHTML;
}
Getting the table column cell text
$('#td1').html('hello world');
$(tbl).find('tr').each(function(){
var currentRow=$(this);
var column_count = 0;
currentRow.find("td").each(function() {
var currentColumn = $(this);
var col_value = currentColumn.text();
});
});
Top comments (0)