如何使用jQuery从定位标记中获取值? [英] How to get the value from anchor tag using jQuery?

查看:76
本文介绍了如何使用jQuery从定位标记中获取值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<a href="" id="a1">myval</a>

如何获取锚标记之间的值,即;这里是"myval",然后将该值指定给一个隐藏的框.我尝试用我的代码来完成此操作,但无法弄清楚.pls帮助

How to get the value which is in between anchor tag ie; here "myval" and then specify that value to a hidden box.I tried do it with my piece of code but couldn't figure it out.pls help

<script type="text/javascript">
    $(document).ready(function(){
        $("#a1").click(function(e){
            //var str=$("#a1").getVal();        
            alert('hello');
        }
    });
</script>

推荐答案

var a1_text = $('#a1').text();

这篇关于如何使用jQuery从定位标记中获取值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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