你應(yīng)該是想全局替換某一個(gè)關(guān)鍵字。
阿里地區(qū)網(wǎng)站制作公司哪家好,找創(chuàng)新互聯(lián)公司!從網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開(kāi)發(fā)、APP開(kāi)發(fā)、成都響應(yīng)式網(wǎng)站建設(shè)等網(wǎng)站項(xiàng)目制作,到程序開(kāi)發(fā),運(yùn)營(yíng)維護(hù)。創(chuàng)新互聯(lián)公司2013年至今到現(xiàn)在10年的時(shí)間,我們擁有了豐富的建站經(jīng)驗(yàn)和運(yùn)維經(jīng)驗(yàn),來(lái)保證我們的工作的順利進(jìn)行。專注于網(wǎng)站建設(shè)就選創(chuàng)新互聯(lián)公司。
選定文本域之后,按下Ctrl + F,選擇里面的相關(guān)選項(xiàng)即可,我認(rèn)為你可以看懂。
//多選框
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);??
});
這是我之前寫(xiě)的? 你照著改改吧
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 腳本實(shí)現(xiàn)吧兄弟
為選擇按鈕注冊(cè)點(diǎn)擊事件{
$(".每一個(gè)車位div").attr( 屬性名: 屬性值);
}
讓每一個(gè)車位都有相同的class
attr 后面就為他設(shè)置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 新建, 打開(kāi), 保存, 退出, 復(fù)制, 粘貼, 剪切, 全選, 字體, 關(guān)于;
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);
打開(kāi) = new JMenuItem("打開(kāi)");
打開(kāi).addActionListener(this);
保存 = new JMenuItem("保存");
保存.addActionListener(this);
退出 = new JMenuItem("退出");
退出.addActionListener(this);
復(fù)制 = new JMenuItem("復(fù)制");
復(fù)制.addActionListener(this);
粘貼 = new JMenuItem("粘貼");
粘貼.addActionListener(this);
剪切 = new JMenuItem("剪切");
剪切.addActionListener(this);
全選 = new JMenuItem("全選");
全選.addActionListener(this);
字體 = new JMenuItem("字體");
字體.addActionListener(this);
關(guān)于 = new JMenuItem("關(guān)于");
關(guān)于.addActionListener(this);
mb.add(文件);
mb.add(編輯);
mb.add(格式);
mb.add(幫助);
文件.add(新建);
文件.add(打開(kāi));
文件.add(保存);
文件.add(退出);
編輯.add(復(fù)制);
編輯.add(粘貼);
編輯.add(剪切);
編輯.add(全選);
格式.add(字體);
幫助.add(關(guān)于);
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(), "文件內(nèi)容已經(jīng)變動(dòng),是否保存?", "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(打開(kāi))){
if(isDirty()){
int ret = JOptionPane.showConfirmDialog(getContentPane(), "文件內(nèi)容已經(jīng)變動(dòng),是否保存?", "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(復(fù)制)){
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(關(guān)于)){
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, "標(biāo)準(zhǔn)");
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("關(guān)于");
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();
}
});
}
}
}