Tutorial :Is this a valid jquery statement?



Question:

Can i apply style like this,

$('#aspnetForm').append($('#facebox .content').html().css({ 'display': 'none' })); but it didnt work...

EDIT:

i am trying to use jquery facebox in asp.net.. i am having issues with the close button.. hide jquery facebox modal manually


Solution:1

.html() returns a string. It doesn't have a css method. You can wrap the html in another element, hide it, then append it for fine-grained control:

var html = $('<div/>').html( $('p:first').html() ).css({'display':'none'}).appendTo('body')  

You can also manipulate it directly by calling .css first, on the element(s).


Solution:2

What are you trying to do that you can't accomplish by using .hide()?

$('#facebox .content').hide();  


Solution:3

html() returns a string so you cannot apply a jQuery method on it. Switch the methods:

$('#aspnetForm').append($('#facebox .content').css({ 'display': 'none' }).html());  

Of course you have to be carful with elements inside '#facebox .content' that have an ID. An ID has to be unique throughout the page.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »