点击按钮修改a标签的地址和热点文字

<script>
 
  //根据id获取按钮,注册点击事件,添加事件处理函数
  //  document.getElementById("btn").onclick = function () {
   
  //    //根据id获取超链接,设置href属性
  //    document.getElementById("ak").href = "http://www.nihao.cn";
  //    //根据id获取超链接,设置文字内容
  //    document.getElementById("ak").innerText = "你好";
  //  };
 
  //优化后的:
 
  document.getElementById("btn")
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
修改Vue input上传组件的按钮和输入框文字,可以通过自定义组件来实现。下面是一个示例代码: ``` <template> <div> <label :for="inputId">{{ label }}</label> <div class="custom-file"> <input type="file" :id="inputId" class="custom-file-input" @change="onFileChange" :accept="accept" :multiple="multiple"> <label :for="inputId" class="custom-file-label">{{ buttonText }}</label> </div> </div> </template> <script> export default { props: { inputId: { type: String, default: 'file-input' }, label: { type: String, default: 'Choose file' }, accept: { type: String, default: '' }, multiple: { type: Boolean, default: false }, buttonText: { type: String, default: 'Browse' } }, methods: { onFileChange(e) { // 处理文件上传逻辑 } } } </script> <style> .custom-file-input::-webkit-file-upload-button { visibility: hidden; } .custom-file-input::before { content: '{{ buttonText }}'; display: inline-block; background: #007bff; color: #fff; border-radius: 5px; padding: 8px 20px; outline: none; white-space: nowrap; -webkit-user-select: none; cursor: pointer; font-weight: 400; margin-right: 10px; } .custom-file-input:hover::before { background: #0069d9; } .custom-file-input:active::before { background: #0062cc; } .custom-file-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; } </style> ``` 这个组件可以通过 `inputId` 属性来指定文件输入框的 `id`,通过 `label` 属性来指定标签文字,通过 `accept` 属性来指定文件类型,通过 `multiple` 属性来指定是否允许多选,通过 `buttonText` 属性来指定按钮文字。 在样式中,通过 `::before` 伪类来修改按钮样式,通过 `.custom-file-label` 类来修改输入框文字样式。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值