Failed in jquery mouseover/hover

jaylimix

New Member
Im unable to change the "My available bids" number 50 to become "Buy". Tried several ways using mouseover/hover but failed. Thanks for help in advance.:)

HTML:
<div id="welcome" align="right">
    
    <?php
        $username= $_SESSION['username'];
        echo "Welcome ".$username."<p/>";
    ?>
    My Available Bids:
    <div id="available_bids">
        <a href="#">
            <?php
                include "connect.php";

                $query= "SELECT * FROM member WHERE username= '$username'";
                $result= mysql_query($query);
                $record= mysql_fetch_object($result);
                $available_bids= $record->available_bids;
                echo $available_bids;
            ?>
        </a>
    </div>
    <br/>
    <div id="my_profile"><a href="#">My Profile</a></div>
    <br/>
    <a href="logout.php" id="sign_in">Logout</a>
</div>

<script src="jquery.js"></script>

<script src="text/javascript">
    
    $(document).ready(function(){
        
        $('#available_bids').hover(function(){
       
        $(this).text("Buy");
       
        });
    });
    
    
</script>
 

Attachments

  • Untitled.jpg
    Untitled.jpg
    15 KB · Views: 36

Phreaddee

Super Moderator
Staff member
HTML:
<script type="text/javascript">
$('#available_bids').contents().each(function() {     
if(this.nodeType == 3)         
this.nodeValue = this.nodeValue.replace("50", "Buy"); 
}
);
</script>
???
 

jaylimix

New Member
HTML:
<script type="text/javascript">
$('#available_bids').contents().each(function() {     
if(this.nodeType == 3)         
this.nodeValue = this.nodeValue.replace("50", "Buy"); 
}
);
</script>
???

It doesnt work. Okay here's the exact code I typed in.

HTML:
<script src="jquery.js"></script>

<script src="text/javascript">
    
    $("#available_bids").mouseover(function(){
        
        $('#available_bids').contents.each(function(){
           if(this.nodeType ==3)
               this.nodeType= this.nodeType.replace("50","Buy");
        });
        
    });
    
    
</script>

Question. The 50 is not actually static(it changes), could I still use replace like this?
 
Question.. now.. Im assuming from a function standpoint your looking to start at 50 and reduce the number by each bid until 0?
 
Top