網站首頁 編程語言 正文
jquery點擊獲取動態數據進行傳參
因為要點擊事件進行跳轉頁面,將當前頁面的部分數據進行傳參
$(".otd").click(function () {
? ? ? ? var _phone = $(this).prev()[0].innerHTML;
? ? ? ? sessionStorage.setItem("_phone",_phone);
? ? ? ? var _name=$(this).prevAll()[1].innerText;
? ? ? ? sessionStorage.setItem("_name",_name);
? ? }
);
jquery .click()方法傳參
今天寫東西,要在jQuery 的.click方法里傳參,查閱了一下jQuery的官方文檔,做了下實驗和總結(原諒我的前端 是用一點學一點?。?/p>
1.click()方法簡介
1.click( handler ) //1.0版本的.click,
? ? ? ? ? ? ? ? ? //handler(Function 類型),只要事件被觸發,就會執行該function
2.click( [eventData ], handler )//1.4.3版本加入的
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//參數eventData:可以為任何數據類型,保存在event.data中,event為handler的一個事件參數
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//參數handler,為Function類型,例:function(event){}
2.寫段代碼測試一下
<html>
? <head>
? ? <title></title>
? ? <meta content="">
? ? <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
? ? <script>
? ? ? $(document).ready(function(){
? ? ? ?$("#btn").click("測試數據",function(event){
? ? ? ? ?alert(event.data);
? ? ? ?})
? ? ? });
</script>
? ? <style></style>
? </head>
? <body>
? ? <button type="button" id="btn">click</button>
? </body>
</html>
原文鏈接:https://blog.csdn.net/qq_43711515/article/details/123041208
相關推薦
- 2022-11-02 React+Mobx基本使用、模塊化操作_React
- 2022-05-21 DaemonSet服務守護進程的使用場景_服務器其它
- 2022-05-10 spring管理事務@Transactional注解相關參數
- 2022-06-06 node中,如何手動實現觸發垃圾回收機制
- 2022-08-19 python循環之彩色圓環實現示例_python
- 2024-03-15 Gitea Webhook報錯 webhook.ALLOWED_HOST_LIST setting
- 2022-07-13 FileInputStream與BufferedInputStream的區別
- 2022-07-06 Android中ViewFlipper和AdapterViewFlipper使用的方法實例_Andr
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支