I have the following HTML code in the backend, ie.

我在后台有如下的HTML代码。

<div class="navi">
  <a class="" href="0"></a>
  <a class="" href="1"></a>
  <a class="" href="2"></a>
  <a class="" href="3"></a>
</div>

Apologies for the basic question but I would like to use jQuery to capture the user's click when they only click on the href value of "0"

很抱歉这个基本的问题但是我想用jQuery捕获用户的点击当他们只点击href值"0"时

Basically want to hide a div called "info" when the user clicks on the where the href="0"

当用户点击href="0"时想要隐藏一个叫"info"的div

Unsure how to do?

不知道怎么办?

Thanks.

谢谢。

1 个解决方案

#1


8

You can use the attribute-equals selector, like this (though I don't think that's a valid href):

您可以使用attribute-equals选择器,就像这样(尽管我不认为这是一个有效的href):

$("a[href=0]").click(function() {
  $("#info").hide();
});

A better approach, if possible, would be to give the <a> a better href that points to the <div>, like this:

如果可能的话,更好的方法是为< A >提供一个指向

的更好的href,如下所示:

更多相关文章

  1. Yii - 加载ajax表单元素的用户端验证
  2. EasyUI动态展示用户信息
  3. 请教一下ajax代替frame在后台管理系统布局上应当怎么应用?
  4. j2ee的web项目,有最终的html代码(即f12看到的最终给用户浏览器展示
  5. golang写服务端程序,作为文件上传与下载的服务器。配合HTML5以网
  6. 维护Java应用程序的多种形式的用户指南
  7. 我正在尝试使用带有post方法的AJAX将用户名和密码发送到php文件
  8. iframe调用后台方法通过response返回html代码
  9. HTML5用户身份认证源代码:注册、登录、会话保持的解决方案

随机推荐

  1. android修改进程名
  2. android 流量统计
  3. Android安装和卸载程序
  4. selector
  5. Android程序怎么做单元测试
  6. 制作登录界面的布局时候,可以使用 android
  7. Android 把从网络获取的图片缓存到内存中
  8. android 设置全屏的三种方式
  9. Android用SharedPreferences记住用户名
  10. Android简单实现音乐播放器