Jump to content
php.lv forumi
  • 0

Js in IE


Question

Posted

Kapēc IE nestrādā šis kods?

jQuery ir pareizs.

ar $.get() arī IE nestrādāja :(

 


function setActive(id,page)
{
document.getElementById('1').setAttribute('class','');
document.getElementById('2').setAttribute('class','');
document.getElementById('3').setAttribute('class','');
document.getElementById('4').setAttribute('class','');
document.getElementById('5').setAttribute('class','');

document.getElementById(id).setAttribute('class','active');
$('#content').load('pages/'+page+'.php');
return false;
}

6 answers to this question

Recommended Posts

  • 0
Posted (edited)

Ja jau izmanto jQuery, tad labāk būtu kaut kā tā (jāpielāgo pēc reālās situācijas):

 

$('#'+id).addClass("active").siblings().removeClass("active");
$('#content').load('pages/'+page+'.php');

Edited by codez
  • 0
Posted (edited)

  • #id nevar buut cipars
  • lieto klases pirmo 5 funkcijas rindinju aizstaashanai
  • ja jau izmanto jQuery tad nelieto document.getElementById, bet gan $(selector)
  • pages/{PAGE}.php eksistee?

Edited by rATRIJS
  • 0
Posted (edited)

update

 


<script type="text/javascript" language="javascript">
function setActive(id,page)
{
$('#'+id).addClass("active").siblings().removeClass("active");
$('#content').fadeOut('slow').load('pages/'+page+'.php').fadeIn('slow');
return false;
}
</script>

<li id="viens" onclick="setActive('viens','index')"><a href="#">Sākums</a></li>

 

un uz visiem pārlūkiem izņemot IE strādā.

Edited by eT`
  • 0
Posted

click eventus arī vajadzētu piešķirt ar jQuery

piešķir ul klasi, piemērā, abc.

 

Tad:

 

$(function(){

 $('.abc li').click(function(){
var page=$(this).attr('page');
$(this).addClass("active").siblings().removeClass("active");
$('#content').load('pages/'+page+'.php');
 });
});

 

 

markups attiecīgi

 


<ul class="abc">
 <li page="index">lalal</li>
 <li page="help">lalal</li>
</ul>

 

 

P.S. Bet tas, ka IE nestrādā, paskaties vai kaut kur nav console... aizmirst vai kaut kas tāds.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...