Show/Hide
1. Write js function
2. Add the id attribute to the html element to be displayed/hidden
控制这个tr的显示/隐藏 |
3, add buttons, links, etc. to trigger the js function
显示/隐藏 javascript显示隐藏层
2: Two methods for javascript to control the hiding and display of page controls
Two methods for javascript to control the hiding and display of page controls. The difference between the methods is whether the control still occupies space on the page after it is hidden
Method one:
document.all["PanelSMS"].style.visibility="hidden"; document.all["PanelSMS"].style.visibility="visible";
Method two:
document.all["PanelSMS"].style.display="none"; document.all["PanelSMS"].style.display="inline";
After method one is hidden, the position of the page is still occupied by the control but it is not displayed
Method two is after hiding the page The position is not occupied
Create/Delete
If I want to create a div element.
1. Create using DOM objects:
Use document.createElement('div') method to create elements.
2. Use JQuery to create:
Use the $('
If you need to delete the div element with the ID 'div2js'.
1. Using the DOM object
First you need to find the parent element of the deleted element, and delete the child elements that need to be deleted through the parent element.
var el = document.getElementById('div2js'); el.parentNode.removeChild(el);
2. Use JQuery
to find and delete directly.
$('#div2js').remove();
Finally let’s look at an example
姓名: