javascript - 通过Js发送时如何隐藏名字

标签 javascript php

I am sending Data like this way But On anchor Hover Its showIng the table name how can i hide the table name and access this name in that function :

<a href='javascript:item(1,'name');'> </a>

$list->table_name This showing the Table name on the hover of anchor how can i hide and access the same name in that Item function.

最佳答案

您可以使用data-*属性。这将在悬停时隐藏它,但它将位于 DOM 上.

<a href='javascript:item(".$list->id.");' data-table-name='\"".$list->table_name."\"'> </a>

输出应如下所示($list->id = 1 且 $list->table_name = my_table 时):

<a href='javascript:item("1");' data-table-name='my_table'> </a>

然后您可以使用 JavaScript 访问它Element.getAttribute() 功能。

例如:

var e = document.getElementById('some-id'),
    tableName = e.getAttribute('data-table-name');
    
console.log(tableName); // my_table
<a id="some-id" href='javascript:item("1");' data-table-name='my_table'> </a>

关于javascript - 通过Js发送时如何隐藏名字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46211185/

相关文章:

javascript - 在 typescript 中扩展 Angular 全局对象

javascript - 通过 AJAX 将 HTML 转换为 PHP 表单输入

javascript - 为多选选择的 Angular

php - MySQL、PhP 和 Flash As3 数据未正确加载?

php - 仅在 safari 和 chrome 中我的网页下方有奇怪的空间

javascript - 如果我的第 3 方 js 脚本嵌入在网站上,如何自动保存每篇新文章的标题

javascript - 在 MySQL 中使用多数据库查询与单数据库查询的比较

javascript - JQuery Ajax 不向 PHP 发送数据

php - MySQL 对一列数据进行排序

javascript - 以编码形式将图像离线存储在 HTML 文件中