jQuery语句与锚问题 [英] Jquery statement with anchor problem

查看:82
本文介绍了jQuery语句与锚问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在jQuery的帮助下单击时,我只想加粗并加下划线(锚)链接....但是不知道如何做....这是我的代码:
ASP.NET语法(切换纯文本)

I want to just bold and underline the (anchor) link when it was clicked with the help of jquery....But didn''t know of how to do it.... Here is my code:
ASP.NET Syntax (Toggle Plain Text)

  <script type="text/javascript" language="javascript">
        $(document).ready(function () {
            $("a").click(function () {

                alert("Hello");

                //                $('.body_text').css('width', '100px');
                //                $('.body_text').css('text-decoration', 'underline');
                //                //this.addClass('makebold');
                //$(this).toggleClass('makebold');
                $(this).css({ "text-decoration": "underline","font-weight": "bold" });
                //$(this).removeClass('makebold');
                //The above code doesn't show this alert is there anything wrong in //writing it as:$('.body_text a').......
                //Some magical code here to bold and underline the selected anchor link //only...
            });
        });
    </script>

<div class="body_wrapper">
    <div id="body_header">
        <div id="body_header_contents_Employees">
            <table cellspacing="18">
                <tr >
                    <td align="center" class="body_text"><a  href="Add_Employee.aspx"><img src="../images/body_header_images/iconEmployees.gif" alt="Add_Employee" title="Add_Employee" border="0" /><br />Add Employee</a></td>
</tr>
</table>
</div></div></div>


剩下的问题是,当我使用此代码并点击锚点时,它会显示一个警告框,并使其本身也以粗体和下划线显示几秒钟,并在页面重新加载或转到锚点的href时立即进行所有修饰变得无效.....即使锚指向同一页面,装饰也将无效.
页面刷新上要执行的操作.............并保持其上的文本修饰


The remaining problem is when I use this code and hit the anchor it shows an alert box of hello and makes itself bold and underline too for a fraction of seconds and as soon as the page reload or goes to the href of the anchor all the decoration becomes void.....even if the anchor refer to the same page the decoration becomes void tooo.
what is to be done on page refreshes.............and maintain the decoration of text on it

推荐答案

(文档).ready(函数(){
(document).ready(function () {


( a").点击(" ); //
("a").click(function () { alert("Hello"); //


('.body_text').css('width', '100px'); //
('.body_text').css('width', '100px'); //


这篇关于jQuery语句与锚问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆