你應該是想全局替換某一個關鍵字。

阿里地區網站制作公司哪家好,找創新互聯公司!從網頁設計、網站建設、微信開發、APP開發、成都響應式網站建設等網站項目制作,到程序開發,運營維護。創新互聯公司2013年至今到現在10年的時間,我們擁有了豐富的建站經驗和運維經驗,來保證我們的工作的順利進行。專注于網站建設就選創新互聯公司。
選定文本域之后,按下Ctrl + F,選擇里面的相關選項即可,我認為你可以看懂。
//多選框
table?id='tab'?width="300"
tr
tdlabelinput?name="mk"?type="checkbox"?value="1"?/XX/label/td
tdlabelinput?name="mk"?type="checkbox"?value="1"?/XX/label/td
/tr
/table
//全選全部選按鈕
input?type="button"?value="全選"??style="width:50px"??id="selectAll"
input?type="button"?value="全不選"?style="width:50px"?id="unSelect"
//事件
$("#selectAll").click(function?()?{
$("#tab?:checkbox,#all").prop("checked",?true);??
});
$("#unSelect").click(function?()?{??
$("#tab?:checkbox,#all").prop("checked",?false);??
});
這是我之前寫的? 你照著改改吧
function selall(obj){
for (var i=0;iobj.elements.length;i++){
var e = obj.elements[i];
if (e.name == 'idd'){
var v=e.checked;
break;
}
}
for (var i=0;iobj.elements.length;i++){
var e = obj.elements[i];
if (e.name == 'id')
e.checked = v;
}
}
全選/反選td style="width:50px;" class="edit"input type="checkBox" name="idd" value="1" onClick="selall(f1)"/td
刪除 td style="width:50px;" class="edit"input type="checkBox" name="id" value="${aa.NId}"/td
用jquery 腳本實現吧兄弟
為選擇按鈕注冊點擊事件{
$(".每一個車位div").attr( 屬性名: 屬性值);
}
讓每一個車位都有相同的class
attr 后面就為他設置style就好了
import javax.swing.*;
import javax.swing.filechooser.FileFilter;
import java.awt.event.*;
import java.awt.*;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Hashtable;
public class MyText extends JFrame implements ActionListener{
private JLabel lb1;
private JMenuBar mb;
private JMenu 文件, 編輯, 格式, 幫助;
private JMenuItem 新建, 打開, 保存, 退出, 復制, 粘貼, 剪切, 全選, 字體, 關于;
private JTextArea editorArea;
private boolean isDirty = false;
private String strFileName = "未命名";
private static final String EDITOR_NAME = "MyText";
public MyText() {
super();
mb = new JMenuBar();
文件 = new JMenu("文件");
編輯 = new JMenu("編輯");
格式 = new JMenu("格式");
幫助 = new JMenu("幫助");
新建 = new JMenuItem("新建");
新建.addActionListener(this);
打開 = new JMenuItem("打開");
打開.addActionListener(this);
保存 = new JMenuItem("保存");
保存.addActionListener(this);
退出 = new JMenuItem("退出");
退出.addActionListener(this);
復制 = new JMenuItem("復制");
復制.addActionListener(this);
粘貼 = new JMenuItem("粘貼");
粘貼.addActionListener(this);
剪切 = new JMenuItem("剪切");
剪切.addActionListener(this);
全選 = new JMenuItem("全選");
全選.addActionListener(this);
字體 = new JMenuItem("字體");
字體.addActionListener(this);
關于 = new JMenuItem("關于");
關于.addActionListener(this);
mb.add(文件);
mb.add(編輯);
mb.add(格式);
mb.add(幫助);
文件.add(新建);
文件.add(打開);
文件.add(保存);
文件.add(退出);
編輯.add(復制);
編輯.add(粘貼);
編輯.add(剪切);
編輯.add(全選);
格式.add(字體);
幫助.add(關于);
setJMenuBar(mb);
Container container = getContentPane();
editorArea = new JTextArea();
editorArea.setLineWrap(true);
editorArea.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if(!isDirty()){
setDirty(true);
}
}
});
JScrollPane scrollPane = new JScrollPane(editorArea);
container.add(scrollPane);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e){
dispose();
}
});
setTitle(formatEditorTitle());
setSize(600, 400);
setVisible(true);
}
private boolean isDirty() {
return isDirty;
}
private void setDirty(boolean isDirty) {
this.isDirty = isDirty;
setTitle(formatEditorTitle());
}
public static void main(String args[]) {
@SuppressWarnings("unused")
MyText app = new MyText();
}
public void actionPerformed(ActionEvent e) {
JMenuItem item = (JMenuItem)e.getSource();
if(item.equals(新建)){
if(isDirty()){
int ret = JOptionPane.showConfirmDialog(getContentPane(), "文件內容已經變動,是否保存?", "MyText", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
if(ret == JOptionPane.OK_OPTION){
saveFile();
}else if(ret == JOptionPane.CANCEL_OPTION || ret == JOptionPane.CLOSED_OPTION){
return;
}
}
clearEditorArea();
setDirty(false);
}else if(item.equals(打開)){
if(isDirty()){
int ret = JOptionPane.showConfirmDialog(getContentPane(), "文件內容已經變動,是否保存?", "MyText", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
if(ret == JOptionPane.OK_OPTION){
saveFile();
}else if(ret == JOptionPane.CANCEL_OPTION || ret == JOptionPane.CLOSED_OPTION){
return;
}
}
openFile();
}else if(item.equals(保存)){
saveFile();
}else if(item.equals(退出)){
dispose();
}else if(item.equals(復制)){
editorArea.copy();
}else if(item.equals(剪切)){
editorArea.cut();
}else if(item.equals(粘貼)){
editorArea.paste();
}else if(item.equals(全選)){
editorArea.selectAll();
}else if(item.equals(字體)){
FontDialog font = new FontDialog(this, editorArea.getFont());
editorArea.setFont(font.getSelectedFont());
}else if(item.equals(關于)){
AboutDialog about = new AboutDialog(this);
about.setVisible(true);
}
}
private String getFileName() {
return strFileName;
}
private void setFileName(String strFileName) {
this.strFileName = strFileName;
}
public String formatEditorTitle(){
StringBuffer strFileNm = new StringBuffer(getFileName());
strFileNm.append(isDirty()?"*":"");
strFileNm.append(" - ");
strFileNm.append(EDITOR_NAME);
return strFileNm.toString();
}
private void clearEditorArea(){
editorArea.selectAll();
editorArea.replaceSelection("");
}
private void openFile(){
JFileChooser openDialog = new JFileChooser();
openDialog.setFileFilter(new TxtFileFilter());
if(openDialog.showOpenDialog(getContentPane()) == JFileChooser.APPROVE_OPTION){
File file = openDialog.getSelectedFile();
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader(file));
String buff = br.readLine();
clearEditorArea();
while(buff != null){
editorArea.append(buff);
editorArea.append("\n");
buff = br.readLine();
}
} catch (FileNotFoundException e1) {
e1.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
} finally{
try{
if(br != null)
br.close();
} catch (IOException ioe){
ioe.printStackTrace();
}
}
}
}
private void saveFile(){
JFileChooser saveDialog = new JFileChooser();
saveDialog.setFileFilter(new TxtFileFilter());
if(saveDialog.showSaveDialog(getContentPane()) == JFileChooser.APPROVE_OPTION){
File file = saveDialog.getSelectedFile();
BufferedWriter bw = null;
try {
bw = new BufferedWriter(new FileWriter(file));
String buff = editorArea.getText();
bw.write(buff);
} catch (IOException ioe) {
ioe.printStackTrace();
} finally{
try{
if(bw != null)
bw.close();
} catch (IOException ioe){
ioe.printStackTrace();
}
}
}
}
class TxtFileFilter extends FileFilter{
@Override
public boolean accept(File f) {
return f.isDirectory() || f.getName().toLowerCase().endsWith(".txt");
}
@Override
public String getDescription() {
return "*.txt(文本文件)";
}
}
class FontDialog extends JDialog{
private JComboBox cb_FontSize;
private JComboBox cb_FontStyle;
private JComboBox cb_FontNm;
private Font font;
HashtableInteger, String style = new HashtableInteger, String();
public FontDialog(){
this(null, null);
}
public FontDialog(Frame owner, Font font){
super(owner);
this.font = font == null?getFont():font;
setTitle("字體選擇框");
setModal(true);
setResizable(false);
setSize(326, 164);
getContentPane().setLayout(null);
final JLabel lb_FontNm = new JLabel();
lb_FontNm.setText("字體名稱");
lb_FontNm.setBounds(10, 10, 66, 16);
getContentPane().add(lb_FontNm);
cb_FontNm = new JComboBox();
cb_FontNm.setBounds(10, 28, 133, 25);
getContentPane().add(cb_FontNm);
cb_FontStyle = new JComboBox();
cb_FontStyle.setBounds(169, 28, 66, 25);
getContentPane().add(cb_FontStyle);
cb_FontSize = new JComboBox();
cb_FontSize.setBounds(258, 28, 53, 25);
getContentPane().add(cb_FontSize);
final JButton btn_OK = new JButton();
btn_OK.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int styleCode = 0;
for(EnumerationInteger i = style.keys();i.hasMoreElements();){
styleCode = i.nextElement();
if(style.get(styleCode).equals(cb_FontStyle.getSelectedItem()))
break;
}
Font font = new Font(cb_FontNm.getSelectedItem().toString(), styleCode, ((Integer)cb_FontSize.getSelectedItem()).intValue());
setSelectedFont(font);
dispose();
}
});
btn_OK.setText("確定");
btn_OK.setBounds(58, 83, 76, 26);
getContentPane().add(btn_OK);
final JButton btn_Cancel = new JButton();
btn_Cancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dispose();
}
});
btn_Cancel.setText("取消");
btn_Cancel.setBounds(169, 83, 76, 26);
getContentPane().add(btn_Cancel);
final JLabel lb_FontStyle = new JLabel();
lb_FontStyle.setText("字體樣式");
lb_FontStyle.setBounds(169, 10, 66, 16);
getContentPane().add(lb_FontStyle);
final JLabel lb_FontSize = new JLabel();
lb_FontSize.setText("字體大小");
lb_FontSize.setBounds(258, 10, 66, 16);
getContentPane().add(lb_FontSize);
init();
setVisible(true);
}
private void init(){
GraphicsEnvironment gg=GraphicsEnvironment.getLocalGraphicsEnvironment();
String ss[]=gg.getAvailableFontFamilyNames();
for(String s : ss)
cb_FontNm.addItem(s);
if(font != null)
cb_FontNm.setSelectedItem(font.getFamily());
style.put(Font.PLAIN, "標準");
style.put(Font.BOLD, "粗體");
style.put(Font.ITALIC, "斜體");
style.put(Font.BOLD+Font.ITALIC, "粗體斜體");
cb_FontStyle.addItem(style.get(Font.PLAIN));
cb_FontStyle.addItem(style.get(Font.BOLD));
cb_FontStyle.addItem(style.get(Font.ITALIC));
cb_FontStyle.addItem(style.get(Font.BOLD+Font.ITALIC));
if(font != null)
cb_FontStyle.setSelectedItem(style.get(font.getStyle()));
for(int i=8;i23;i++)
cb_FontSize.addItem(i);
if(font != null)
cb_FontSize.setSelectedItem(font.getSize());
}
public Font getSelectedFont() {
return font;
}
public void setSelectedFont(Font font) {
this.font = font;
}
}
class AboutDialog extends JDialog{
public AboutDialog(JFrame owner){
super(owner);
setTitle("關于");
setSize(new Dimension(322, 163));
getContentPane().setLayout(null);
final JLabel version = new JLabel();
version.setText("MyText 1.0");
version.setBounds(74, 37, 66, 16);
getContentPane().add(version);
final JLabel copyright = new JLabel();
copyright.setText("Copyright (C) 2010");
copyright.setBounds(74, 59, 188, 16);
getContentPane().add(copyright);
final JSeparator separator = new JSeparator();
separator.setBounds(70, 90, 210, 2);
getContentPane().add(separator);
final JButton okButton = new JButton();
okButton.setBounds(235, 95, 50, 26);
getContentPane().add(okButton);
okButton.setText("Ok");
okButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dispose();
}
});
}
}
}
分享文章:java代碼實現全選 js怎么實現全選
網頁地址:http://www.js-pz168.com/article48/higgep.html
成都網站建設公司_創新互聯,為您提供網站營銷、品牌網站設計、電子商務、網站改版、動態網站、關鍵詞優化
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯