HTML に行を追加する方法: 最初に HTML サンプル ファイルを作成し、次に table タグを使用してテーブルを作成し、最後に JS コード「function addRow() {...」を使用してテーブルに行を追加します。 }" 方法 。
この記事の動作環境: Windows7 システム、HTML5&&CSS3 バージョン、Dell G3 コンピューター。
HTML テーブルの行の追加と行の削除
主なアイデア: 次に、ページ上に必要な HTML コード スタイルのセクションを記述し、設定します。それを非表示にします (style ="display: none")。次に、js でコードを取得し、処理して、html
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>新增一行</title> </head> <body> <table> <tr> <th>序号</th> <th>姓名</th> <th>电话</th> <th>地址</th> <th>操作</th> </tr> <!--这一行是隐藏的,主要用户方便js中获取html代码--> <!--##:js中会替换成数字--> <tr id="show" style="display: none"> <td>##</td> <td> <input id="name##" /> </td> <td> <input id="phone##" /> </td> <td> <input id="address##" /> </td> <td> <button type="button" onclick="deleteRow('##')">删除</button> </td> </tr> </table> <button type="button" onclick="addRow()">新增一行</button> <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <script > var index = 0;//初始下标 var indexArr= new Array(); //新增一行 function addRow() { index++; indexArr.push(index); var showHtml = $("#show").html(); var html = "<tr id='tr##'>"+showHtml+"</tr>"; html = html.replace(/##/g,index);//把##替换成数字 $("#show").before($(html)); console.log("当前下标数组",indexArr); } //删除一行 function deleteRow(inde){ $("#tr" + inde).remove(); var a = indexArr.indexOf(parseInt(inde)); if (a > -1) { indexArr.splice(a, 1); console.log("当前下标数组",indexArr); } } </script> </body> </html>
に書き戻します。
[推奨学習: html ビデオ チュートリアル ]
以上がHTMLに行を追加する方法の詳細内容です。詳細については、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 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

人気の記事

ホットツール

mPDF
mPDF は、UTF-8 でエンコードされた HTML から PDF ファイルを生成できる PHP ライブラリです。オリジナルの作者である Ian Back は、Web サイトから「オンザフライ」で PDF ファイルを出力し、さまざまな言語を処理するために mPDF を作成しました。 HTML2FPDF などのオリジナルのスクリプトよりも遅く、Unicode フォントを使用すると生成されるファイルが大きくなりますが、CSS スタイルなどをサポートし、多くの機能強化が施されています。 RTL (アラビア語とヘブライ語) や CJK (中国語、日本語、韓国語) を含むほぼすべての言語をサポートします。ネストされたブロックレベル要素 (P、DIV など) をサポートします。

VSCode Windows 64 ビットのダウンロード
Microsoft によって発売された無料で強力な IDE エディター

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

ゼンドスタジオ 13.0.1
強力な PHP 統合開発環境

ZendStudio 13.5.1 Mac
強力な PHP 統合開発環境

ホットトピック









