What to use with Jquery for Div html , innerHtml Or text


What to use with Jquery for Div html , innerHtml Or text?

I was working on project which uses Google maps. We allow users to create polygon on the Google map and when user starts drawing polygon we were to show tool tips, you can read how we are showing tooltips using Jquery on teh googel maps here [http://www.isolutionteam.co.uk/show-tooltip-on-google-map-polygon-drag-handle-using-jquery/].

Tool tip were worked great in all three browsers IE 7, Firefox 3.6.4 and Chrome 4.1.249.  Then there was a requirement to change tool tip text on every click of mouse on the map.  This process invoice to count vertices of polygon on the map.

I E was going  mad on second click when I was using $(“#maptooltipcontainer”).html(toolTipText). but it worked fine with Firefox and chrome versions mentioned above.
Then i changed $(“#maptooltipcontainer”).text(toolTipText). and it started working on all three browsers.


I Wan to share this post:
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • kick.ie
  • Live
  • MyShare
  • IndianPad
  • Reddit
  • StumbleUpon
  • Technorati
  • DotNetKicks
  • DZone
  • email
  • MySpace

Highlight dot net form text box onfocus using jquery

Highlight asp.net text box when it gets focus. When your cursor will focus on text box it will be surrounded by a red rectangle when cursor leaves text it becomes normal. If coursor goes to  button or dropdown list they dont get any style the behave as normal. This code is ony tested in IE7. Do not forget to reference Jquery script in your document. you can get jquery script file from jquery.com

 

CSS Style

<style type=”text/css”>

        .required

        {

            border: solid 1px #ff0000;

            padding: 1px 1px 1px 1px;

        }

</style>

ASP.net Controls

    <div>

      <asp:Label ID=”Label1″ runat=”server”>First Name</asp:Label>

            <asp:TextBox ID=”txtFirstName” unat=”server”></asp:TextBox>

            <asp:Label ID=”Label2″ runat=”server”>Last Name</asp:Label>

            <asp:TextBox ID=”txtLastName” runat=”server”></asp:TextBox>

        </div>

        <asp:Button ID=”Button1″ runat=”server” Text=”Button” />

        <asp:DropDownList ID=”DropDownList1″ runat=”server”>

        <asp:ListItem >1</asp:ListItem>

        <asp:ListItem >1</asp:ListItem>

        <asp:ListItem >1</asp:ListItem>

       

        </asp:DropDownList>

Jquery Code

$(document).ready(function () {

        $(“:text”).focus(function (){

                $(this).addClass(“required”);

            });

               $(“:text”).blur(function () {

                $(this).removeClass(“required”);

               });

            });

OR

$(document).ready(function () {

        $(“input[type=text]“).focus(function (){

                $(this).addClass(“required”);

            });

           

            $(“input[type=text]“).blur(function () {

                $(this).removeClass(“required”);

               });

  });

Following Code give error in IE 7 I haven’t tested in any other browser.  Can any one tell me please why following code is giving error though this code is available on Internet:  $(“input[@type=text]“).

$(document).ready(function () {

        $(“input[@type=text]“).focus(function (){

                $(this).addClass(“required”);

            });

           

            $(“input[@type=text]“).blur(function () {

                $(this).removeClass(“required”);

               });       

 });

I Wan to share this post:
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • kick.ie
  • Live
  • MyShare
  • IndianPad
  • Reddit
  • StumbleUpon
  • Technorati
  • DotNetKicks
  • DZone
  • email
  • MySpace