Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi I want to implement marquee tag in my web from using jquery. in my web from i have text box ,button and div for display the marquee.my requirement is i want to display the textbox text to marquee as sliding after click on button this is my code



ASP.NET
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript"></script>
    <style type="text/css">
    .container { width: 300px;color:Green; font-family:Verdana; font-size:20px;  }
    .ticker { white-space: nowrap; }

    </style>
    <script type="text/javascript">
        $(document).ready(function () {
            
            $("#btn_click").click(function () {
                var textboxvalue = $("#txtbx_data").val();
                var dis = $("#div_scroll").find(".ticker").text(textboxvalue);
                $('.ticker').each(function () {

                var marq = $('<marquee></marquee>').attr({
                    'behavior': 'slide',
                    'scrollamount': 08,
                    'direction': 'left',
                    'width': '100%'
                })
                        $(this).wrap(marq);
                    
                })
            })
        });          


    </script>

</head>
<body>
<div class="container" id="div_scroll">

<div class="ticker"></div>
 
</div>
    <input type="text"  id="txtbx_data" />

<input type="button" value="Click" id="btn_click" />


</body>
</html>




in above code for every texbox text one marquee is created and space of marquee is reducing
Posted
Updated 11-Oct-12 4:19am
v2

1 solution

Hi Babu, check this code.
JavaScript
<script type="text/javascript">
        $(document).ready(function () {
            var movingDiv = $("#div_scroll").find(".ticker");
            $("#btn_click").click(function () {
                var textboxvalue = $("#txtbx_data").val();
                movingDiv.text(textboxvalue).animate({ marginLeft: '550' }, 5000, function () { $(this).animate({ marginLeft: '5' }, 5000) });

            }) 
        });          
    </script>
 
Share this answer
 
v3
Comments
Traybabu 12-Oct-12 4:13am    
in the above the division is moving first right then come left I want only sliding from right please i tried it it working perfect on two side how to get only from one side

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900