2019年3月31日 星期日

改變 Radio Button 的文字 ( Change the text of a radio button )

如果你想要在網頁 Update Radio Button 的文字

通常用的 .val(), .text(), .html() 都沒有辦法

這時應該做的是在 HTML 裡把 Radio Button 的文字用一個Label包起來

然後再使用 .next().html() 去Update Radio Button 的文字

這裡的 Label 我使用的是 span

HTML : 
<input type="radio" name="year" value='1'><span> 1 年 </span>
<input type="radio" name="year" value='2'><span> 2 年 </span>
<input type="radio" name="year" value='3'><span> 3 年 </span>
JS :
tmp = $("input[name='year'][value='3']").next().html();


參考資料 :
https://stackoverflow.com/questions/9945748/how-to-change-the-text-of-a-radio-button

Related Posts:

  • 改變 Radio Button 的文字 ( Change the text of a radio button )如果你想要在網頁 Update Radio Button 的文字 通常用的 .val(), .text(), .html() 都沒有辦法 這時應該做的是在 HTML 裡把 Radio Button 的文字用一個Label包起來 然後再使用 .next().html() 去Update Radio Button 的文字 這裡的 Label 我使用的是 span HTML :  <input type="r… Read More
  • 使用 IE 的理由在公司內部系統,網站會建議使用 Internet Explorer 開啟 原因很簡單,在 IE 裡,一個 html link 可以開啟相同 domain 下的資料夾和檔案 基本上大部分的瀏覽器都會檔,因為安全性的問題。 以 Chrome 為例 <a href="file:///fileserver/test.xls">Test</a> IE 可以直接 Server 上的分享資料夾 只要連結可以轉成… Read More
  • IPv6 筆記 ( 序 + week1 ) 序 工作需求必須從頭到尾了解 IPv6 這項技術 所以好像回到大學時期,重新看了 NTHU 黃能富教授經營的學聯網 ( 課程已關閉 ) 但既然重看了,那就索性作筆記但不會太詳細 ( 因為沒人會考我XD )。 參考資料 http://www.sharecourse.net/sharecourse/course/view/courseInfo/475 Week 1  1. IPv6 之於 IPv4 … Read More
  • CSS vertical-align有時候 Input 的 text 或 textarea 有時候預設的對齊可能不盡理想 這時候可以用 vertical-align,這主要是用來對齊圖片的 但有時候你會想讓 textarea 對齊隔壁的物件,因為沒有此參數的話他會對齊 textarea 的底線 textarea { vertical-align:25px; // 向上修正 25px } 也有支援其他參數,但 w3schools 已有列表這邊不在… Read More
  • Javascript 做簡單的Table Sorting用 Javascript 作 Table Sorting 這裡寫 2 種自己的做法 第一種 w3schools function sortTable() { var table, rows, switching, i, x, y, shouldSwitch; table = document.getElementById("myTable"); switching = true; /* Make a loo… Read More

0 意見:

張貼留言

Popular Posts