src

How to change image with onmouseover in different place that reverts back to default image on the site?

醉酒当歌 提交于 2019-12-20 02:36:22
问题 I'm no expert in this so excuse me if this is very basic but I couldn't find answers. So I want to have navigation section with categories on the left side of the page. Each category is different site, and each site has it's own unique image on it. ex. category1.htm has defaultpic1.jpg, category 2.htm has defaultpic2.jpg, .... When I hover on link to category2 in the nav sections I want them to change default image on current site to default image on category2, and then onmouseout I want it

获取内容中所有指定标签的src

[亡魂溺海] 提交于 2019-12-20 01:58:44
下边这个方法是获取内容中(比如网页)所有的指定标签的src集合,htmlstr为内容,type为标签名称,比如图片标签名称为img(代码块中注释部分即是以img为示例),视频标签为video等 /** * 获取指定类型的src值的集合 * @param htmlStr * @param type 标签名称 * @return */ public static Set < String > getSrcStr ( String htmlStr , String type ) { Set < String > srcs = new HashSet < String > ( ) ; String src = "" ; Pattern p_src ; Matcher m_src ; // String regEx_img = "<img.*src=(.*?)[^>]*?>"; //图片链接地址 String regEx_src = "<" + type + ".*src\\s*=\\s*(.*?)[^>]*?>" ; p_src = Pattern . compile ( regEx_src , Pattern . CASE_INSENSITIVE ) ; m_src = p_src . matcher ( htmlStr ) ; while ( m_src . find ( ) ) {

HTML 中 href、src 区别

随声附和 提交于 2019-12-19 22:17:08
HTML 中 href、src 区别@ TOC href 是 Hypertext Reference 的缩写,表示超文本引用。用来建立当前元素和文档之间的链接。常用的有:link、a。例如: <link href="reset.css" rel=”stylesheet“/> 浏览器会识别该文档为 css 文档,并行下载该文档,并且不会停止对当前文档的处理。这也是建议使用 link,而不采用 @import 加载 css 的原因。 src 是 source 的缩写,src 的内容是页面必不可少的一部分,是引入。src 指向的内容会嵌入到文档中当前标签所在的位置。常用的有:img、script、iframe。例如: <script src="script.js"></script> 当浏览器解析到该元素时,会暂停浏览器的渲染,直到该资源加载完毕。这也是将js脚本放在底部而不是头部得原因。 简而言之,src 用于替换当前元素;href 用于在当前文档和引用资源之间建立联系。 来源: CSDN 作者: weixin_45760431 链接: https://blog.csdn.net/weixin_45760431/article/details/103613702

函数传参,改变Div任意属性的值&&图片列表:鼠标移入/移出改变图片透明度

让人想犯罪 __ 提交于 2019-12-19 09:54:01
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>函数传参,改变Div任意属性的值</title> <style> body,p{margin:0;padding:0;} body{color:#333;font:12px/1.5 Tahoma;padding-top:10px;} #outer{width:300px;margin:0 auto;} p{margin-bottom:10px;} button{margin-right:5px;} label{width:5em;display:inline-block;text-align:right;} input{padding:3px;font-family:inherit;border:1px solid #ccc;} #div1{color:#fff;width:180px

Load a file from src folder into a reader

余生长醉 提交于 2019-12-19 09:16:40
问题 I would like to know how can I load a file lol.txt from src folder into my close method. The code so far: public void close() throws IOException { boolean loadFromClasspath = true; String fileName = "..."; // provide an absolute path here to be sure that file is found BufferedReader reader = null; try { if (loadFromClasspath) { // loading from classpath // see the link above for more options InputStream in = getClass().getClassLoader().getResourceAsStream("lol.txt"); reader = new

vue :src 文件路径错误

删除回忆录丶 提交于 2019-12-18 07:25:22
首先先说明下vue-cli的assets和static的两个文件的区别,因为这对你理解后面的解决办法会有所帮助  assets:在项目编译的过程中会被webpack处理解析为模块依赖,只支持相对路径的形式,如< img src=”./logo.png”>和background:url(./logo.png),”./logo.png”是相对资源路径,将有webpack解析为模块依赖  static:在这个目录下文件不会被webpack处理,简单就是说存放第三方文件的地方,不会被webpack解析。他会直接被复制到最终的打包目录(默认是dist/static)下。必须使用绝对路径引用这些文件,这是通过config.js文件中的build.assetsPublic和build.assertsSubDirectory链接来确定的。任何放在static/中文件需要以绝对路径的形式引用:/static[filename]  根据webpack的特性,总的来说就是static放不会变动的,第三档的文件,asserts放可能会变动的文件 问题来了,用js动态加载assets或者本文件的图片出现404的状态码 代码实例 1 2 3 4 5 6 7 8 <li v- for = "(item,index) in images" :key= "index" > <img :src= "item.src"

changing the img src with jquery

孤人 提交于 2019-12-18 03:57:15
问题 The html structure I have is something like: <ul id="something"> <li> <a href=""> <img src="http://domain.com/directory/file1-128x79.jpg"> </a> </li> <li> <a href=""> <img src="http://domain.com/directory/file2-128x79.jpg"> </a> </li> <li> <a href=""> <img src="http://domain.com/directory/file3-128x79.jpg"> </a> </li> </ul> I'm trying to change the filename from file#-128x79.jpg to file#-896x277.jpg . I don't know how to take the dynamically generated filename and search and replace for the

Add transition while changing img src with javascript

北战南征 提交于 2019-12-18 03:53:41
问题 I have an img tag that I want to change the src when hover and it all works but i would like to add some transition so it doesn't look so rough but since it's an img src i cant target it with css. http://jsfiddle.net/Ne5zw/1/ html <img id="bg" src="img/img1.jpg"> <div onmouseover="imgChange('img/img2.jpg'); "onmouseout="imgChange('img/img1.jpg');"> js function imgChange(im){ document.getElementById('bg').src=(im); } 回答1: You want a crossfade. Basically you need to position both images on top

What is the right way to write my script 'src' url for a local development environment?

99封情书 提交于 2019-12-18 01:56:15
问题 I'm working on a local environment and I'm not sure if I've written my src URl correctly because my functions aren't working. The bold script tag has the src in question. <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script> <script src="http://www.parsecdn.com/js/parse-1.2.2.min.js"></script> **<script src="/Users/myUserName/Desktop/myPage.js"></script>** </head> <body> <div id="mainDiv"> <p><a href="#">anchor</a></p> </div> <

js--判断资源是否存在

落爺英雄遲暮 提交于 2019-12-18 01:24:43
js--判断资源是否存在 desc 实现原理 code desc 在实际业务开发中,我们常会遇到条件渲染的问题,比如图片。当目标图片存在,则显示目标图片,不存在则显示默认的占位图片。如果在服务端(比如nodejs)很好实现,fs模块的 existsSync 方法就可以解决,但是前端,需要手动写一些逻辑判断 实现原理 在html标签中,具有src属性的标签在给其赋值时,会立刻发起一次异步请求,而且支持跨域。比如script标签,img标签,前者是jsonp的关键,后者是图片懒加载的关键。对img标签而言,例用src设置后的异步请求和onload,onerror可以检测资源是否存在。 code checkImgExist接收三个参数,目标路径,成功回调和失败回调。onload,onerror 请求都是异步操作,必须通过回调函数处理其他逻辑 function checkImgExist ( src , successCallback , errorCallback ) { var img = new Image ( ) img . src = src img . onload = function ( ) { successCallback ( src ) ; } img . onerror = function ( ) { errorCallback ( defaultImg ) ;