網(wǎng)站首頁 編程語言 正文
jquery點擊獲取動態(tài)數(shù)據(jù)進行傳參
因為要點擊事件進行跳轉頁面,將當前頁面的部分數(shù)據(jù)進行傳參
$(".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的官方文檔,做了下實驗和總結(原諒我的前端 是用一點學一點!)
1.click()方法簡介
1.click( handler ) //1.0版本的.click,
? ? ? ? ? ? ? ? ? //handler(Function 類型),只要事件被觸發(fā),就會執(zhí)行該function
2.click( [eventData ], handler )//1.4.3版本加入的
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//參數(shù)eventData:可以為任何數(shù)據(jù)類型,保存在event.data中,event為handler的一個事件參數(shù)
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//參數(shù)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("測試數(shù)據(jù)",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-03-23 .NET微服務架構CI/CD自動打包鏡像_實用技巧
- 2022-09-06 python?OpenCV的imread不能讀取中文路徑問題及解決_python
- 2022-01-17 element日期時間選擇器提交時間格式不準確
- 2022-10-14 Sklearn中predict_proba函數(shù)用法及原理詳解
- 2022-07-03 DatePicker動態(tài)設置picker-options 中的disabledDate屬性操作;
- 2022-07-13 簡單的利用boost.python 和 boost.numpy 實現(xiàn)python和c++之間數(shù)據(jù)通信
- 2022-01-17 如何實現(xiàn) input 和 textarea 自動聚焦
- 2022-06-04 tomcat的catalina.out日志按自定義時間格式進行分割的操作方法_Tomcat
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細win安裝深度學習環(huán)境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結構-簡單動態(tài)字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支