Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Mar 2011
    Posts
    147
    Thanks
    35
    Thanked 0 Times in 0 Posts

    weird javascript problem: no errors thrown & no feedback

    For some reason i cant get this bit of code to work. You can ignore the php and html if its getting in your way. Thanks:

    Code:
    <div id="pl">
    												<?
    												if($edit == true){
    												?>
    												<script type="text/javascript">
    													$("#add_playlist_form").css({display:"none"});
    													$("#add_playlist").click(function(){
    														alert($("#add_playlist").html());
    														if($("#add_playlist").html() == "Add a Playlist >>"){
    															$("#add_playlist").html("Hide <<");
    															$("#add_playlist_form").css({display:"block"});
    														}
    														else{
    															$("#add_playlist").html("Add a Playlist >>");
    															$("#add_playlist_form").css({display:"none"});
    														}
    													});
    												</script>
    												<a href="#" id="add_playlist">Add a Playlist >></a>
    												<form id="add_playlist_form" method="POST" action=" ">
    													<input type="text" name="pl_name" class="add_playlist"/>
    													<textarea name="pl_dsec" maxlength="200"></textarea>
    													<input type="submit" name="submit_playlist" value="Add Playlist" class="submit_playlist"/>
    												</form>
    												<?
    												}
    												?>
    												<ul class="vList">

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,355
    Thanks
    11
    Thanked 558 Times in 551 Posts
    This is a simple $(document).ready() problem ... has been mentioned many times here (nearly every day!)

    Code:
    $(document).ready(function() {
       // your code goes here
    });


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •