Tuesday, 24 July 2012

how to check element visibility in jquery?

example of element exists and it’s not visible


<div id="test">
<div id="test_1" style="display:none">
Hello World!
</div>
</div>


jQuery code:
if ($('#test_1:visible').length > 0)
{
alert('the element is visible');
}
else
{
alert('the element is not visible');
}


Tuesday, 3 July 2012

how to replace & or special characters in javascript?

//if  value of catnm='art & jewllery';

//then i want need to replace "&".

//because when i will try to post data using jquery then jquery know this is query string.....so i want to need  to replace "&"  using "URL ENCODED CHARACTERS"

//so,see below example

var catnm=document.getElementById('catnm').value;

var cat_re=catnm.replace('&','%26');

OUTPUT 

In Javascript alert box  : art %26 jewllery

In html format(in web browser )  : art & jewllery

Please refer below website for URL Encode Characters

http://www.degraeve.com/reference/urlencoding.php

http://www.w3schools.com/tags/ref_urlencode.asp