I've commented your code below:
if (x!="") // if x is not "" - let's assume it's true
{
if (x="no") // here you assign x value "no" - so the if is similar to if("no")
{
// since x="no" happens to be "truthy" this block code will execute and will HIDE the div with class .text
$('.text').hide('slow');
$('#less').attr('style','display: none;');
$('#more').attr('style','display: block;');
}
if (x="yes") //here you assign x value "yes" - again this is similar to writing if("yes")
{
// since x="yes" is again "truthy" this code block will execute also SHOWING the div with class .text
$('.text').show('slow');
$('#less').attr('style','display: block;');
$('#more').attr('style','display: none;');
}
}
So you should switch to x=="no"
and x=="yes"
or better yet to always use ===
for equality operator and !==
for inequality operator in javascript.