jQuery :has()
此選擇器匹配含有選擇器所匹配的元素的元素。
jQuery1.14版本新增。
語法結構:
[JavaScript] 純文字檢視 複製程式碼jQuery( ":has(selector)" )
程式碼例項:
[HTML] 純文字檢視 複製程式碼執行程式碼<!DOCTYPE html> <html> <head> <meta charset=" utf-8"> <meta name="author" content="http://www.softwhy.com/" /> <title>螞蟻部落</title> <style type="text/css"> div { width:100px; height:50px; background-color:#ccc; margin:5px; } span{border:1px solid blue;} </style> <script src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#bt").click(function () { $("div:has(span)").css("background-color", "green") }) }) </script> </head> <body> <div>螞蟻部落一</div> <div> <span>螞蟻部落二</span> </div> <input type="button" value="檢視效果" id="bt" /> </body> </html>
將含有span元素的div元素背景顏色設定為綠色。
相關文章
- jQuery has()jQuery
- oracle hasOracle
- AttributeError: 'dict' object has no attribute 'has_key'ErrorObject
- [CSS 3] :has()CSS
- oracle has a disk HB, but no network HB, DHB has r cfg , wrtcntOracle
- yarn certificate has expiredYarn
- MySQL server has gone awayMySqlServerGo
- Python has two GILsPython
- RuntimeError: An attempt has been made to start a new process before the current process hasError
- Process object has no attribute '_popen'Object
- ‘dict‘ object has no attribute ‘iteritems‘Object
- He also has best iphone casesiPhone
- An out of memory error has occurred.Error
- How has JBuilder 8 source codeUI
- getOutputStream() has already been called
- Teamcenter 《POM has not start》處理
- “setting.xml” has syntax errorsXMLError
- akka-typed(3) - PersistentActor has EventSourcedBehavior
- 問題MySQL server has gone awayMySqlServerGo
- Window Application has "update" key wordsAPP
- Uncaught TypeError: Object # has no method 'load'ErrorObject
- 關於“Client 000 has status ‘not modifiable’”client
- SELinux has to be disabled on RHEL/OEL 5Linux
- CSS父級選擇器 :has()CSS
- has(),find()以及filter()方法的區別Filter
- ‘FirewallD‘ object has no attribute ‘path‘ 、‘fw‘、is not registeredObject
- An internal error has occurred. Java heap spaceErrorJava
- AttributeError: 'module' object has no attribute 'lock'ErrorObject
- MySQL server has gone away 解決方案MySqlServerGo
- The installer has not detected any Oracle 10.2.0.4.0Oracle
- JIRA startup failed, JIRA has been locked.AI
- InnoDB Plugin has been upgraded to version 1.0.8Plugin
- WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!REMIDE
- jQuery初探:自制jQueryjQuery
- module ‘h5py‘ has no attribute ‘File‘H5
- 【坑】Tkinter ‘NoneType‘ object has no attribute ‘destroy‘NoneObject
- AttributeError: module ‘requests‘ has no attribute ‘_version_‘Error
- AttributeError: 'Settings' object has no attribute 'HBase'ErrorObject