メソッド: 1. 指定された要素のすべての兄弟要素を返すには、兄弟() メソッドを使用します。構文は、「element object.siblings()」です。 2. 属性を削除するには、removeAttr() メソッドを使用します。構文は「兄弟要素 object.removeAttr(attribute)」です。
このチュートリアルの動作環境: Windows10 システム、jquery3.2.1 バージョン、Dell G3 コンピューター。
jquery で兄弟要素の属性を削除する方法
1. 兄弟要素を取得する
siblings() メソッドは、選択した要素のすべての兄弟要素を返します。 。
兄弟要素とは、同じ親要素を共有する要素です。
DOM ツリー: このメソッドは、DOM 要素の兄弟要素に沿って前後にトラバースします。
ヒント: 前の兄弟要素または次の兄弟要素のみを検索する範囲を狭めるには、 prev() または next() メソッドを使用してください。
構文
$(selector).siblings(filter)
2. 兄弟要素属性の削除
removeAttr() メソッドは、選択した要素から 1 つ以上の属性を削除します。
構文
$(selector).removeAttr(attribute)
パラメータの説明
属性 必須。削除する 1 つ以上のプロパティを指定します。複数のプロパティを削除するには、プロパティ名をスペースで区切ります。
例は以下のとおりです。
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>123</title> <style> .siblings *{ display: block; border: 2px solid lightgrey; color: lightgrey; padding: 5px; margin: 15px; } </style> <script src="js/jquery.min.js"> </script> <script> $(document).ready(function(){ $("li.start").siblings().removeAttr("style"); }); </script> </head> <body> <div style="width:500px;" class="siblings"> <ul>ul (父节点) <li style="color:red">li (类名为"star"的上一个兄弟节点)</li> <li style="color:red">li (类名为"star"的上一个兄弟节点)</li> <li class="start">li (兄弟节点)</li> <li style="color:red">li (类名为"star"的下一个兄弟节点)</li> <li style="color:red">li (类名为"star"的下一个兄弟节点)</li> </ul> </div> <p>在这个例子中,我们选择类名称为“star”的li元素的所有兄弟元素。</p> </body> </html>
jquery 文を追加しない場合の出力結果:
jquery 文を追加した後の結果の出力:
推奨される関連ビデオ チュートリアル: jQuery ビデオ チュートリアル
以上がjqueryで兄弟要素の属性を削除する方法の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

usestate()isareacthookusedtomeStateinfunctionalComponents.1)itInitializeSandUpDatestate、2)colledatttheToplevelofComponents、3)canleadto'stalestate'ifnotusedly、and4)cancancancancancanbeoptimizeduptimizeduptimizedususecall -calleSuperesteSteSteSteSteSteSteSteSteStateSupteStateSuptateSuptatedates

ReactisPopularduetoitsComponent Architecture、Virtualdom、Richecosystem、およびdeclarativenature.1)コンポーネントベースのarchitectureallowsforReusable anduipieces、改善様式および測定可能性。

debugReactapplicationivivivity、EtheseStrategies:1)AddressPropdrillingWithContextapiorredux.2)HandLeasynchronousoperations withuthutateanduseeffect、Abortcontrollertopreventraceconditions.3)最適化合物を使用して、最適化合物を使用してください

UseState()inReactallowsstateManagementInFunctionalComponents.1)itsimplifiesstateManagement、makeCodemoreconcise.2)usetheprevcountFunctionToupDateStateBasedTateBasedTateBadeStateValue、AvolidingStalestateSues.3)

ChooseuseState()forsimple,independentstatevariables;useuseReducer()forcomplexstatelogicorwhenstatedependsonpreviousstate.1)useState()isidealforsimpleupdatesliketogglingabooleanorupdatingacounter.2)useReducer()isbetterformanagingmultiplesub-valuesorac

UseStateは、州の管理を簡素化し、コードをより明確にし、読みやすくし、Reactの宣言的な性質と一致するため、クラスコンポーネントやその他の州管理ソリューションよりも優れています。 1)UseStateを使用すると、状態変数を関数コンポーネントに直接宣言することができます。2)フックメカニズムの再レンダリング中に状態を覚えています。

useUsestate()forlocalcomponentStatemanagement; compleartinative forglogic、orperformanceissues.1)useidealforsimple、localstate.2)useglobalStateSolutionSolutionSuxorContextForSharedState.3)OptForreDuxtormobxobxobxobforexSt

再利用することは、codecodemaintainabilityを抑制することを再生します


ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

Video Face Swap
完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

人気の記事

ホットツール

SublimeText3 中国語版
中国語版、とても使いやすい

SAP NetWeaver Server Adapter for Eclipse
Eclipse を SAP NetWeaver アプリケーション サーバーと統合します。

WebStorm Mac版
便利なJavaScript開発ツール

SublimeText3 Linux 新バージョン
SublimeText3 Linux 最新バージョン

MinGW - Minimalist GNU for Windows
このプロジェクトは osdn.net/projects/mingw に移行中です。引き続きそこでフォローしていただけます。 MinGW: GNU Compiler Collection (GCC) のネイティブ Windows ポートであり、ネイティブ Windows アプリケーションを構築するための自由に配布可能なインポート ライブラリとヘッダー ファイルであり、C99 機能をサポートする MSVC ランタイムの拡張機能が含まれています。すべての MinGW ソフトウェアは 64 ビット Windows プラットフォームで実行できます。

ホットトピック









