shujaat siddiqui
shujaat siddiqui

Reputation: 1577

Remove Text Box Element From HTML Source

I am using asp.net MVC3 . i have a button in my application and i want to hide to my textbox on button click. Problem is it hides on button click but when you do inspect element it shows the textbox element with property disabled . and if user change the property i will be enabled again.

I want to hide the complete element from HTML Source

Upvotes: 0

Views: 218

Answers (1)

iCollect.it Ltd
iCollect.it Ltd

Reputation: 93561

Use jQuery's .remove() on the element to remove it from the DOM completely:

e.g

$('.mytextclass').remove();

To re-add it, use append()

e.g.

$('.mytextcontainerclass').append('<input type="text" class="mytextclass"/>')

You can hide and show elements in any number of ways. If you only care about the enabled state being "hacked", use .hide() and .show() instead.

Another option: You can detach the element and store it in a global variable, or elsewhere in the DOM, then put it back later.

Upvotes: 1

Related Questions