導航:首頁 > 文字圖片 > jquery按文字改變圖片

jquery按文字改變圖片

發布時間:2022-06-21 03:35:33

㈠ 一段滑鼠經過文字顯示圖片的jquery代碼

我看了代碼,css和js都有點小問題,我簡單改了一下

css問題。

.pcdownp.show{display:block;}

上面那段代碼比原來的p.show優先順序高,所以沒效果。

js是下面這么改,這么改js,上面的css可以不用,js直接就控制隱藏和顯示。

$(function(){
$('.pcdownli').mouseover(function(){
$(this).siblings().find('p').hide();
$(this).find('p').show();
});
});

先把所有的p隱藏,然後顯示當前的。就行了。測試有效

㈡ jquery中如何做到滑鼠經過文字顯示圖片

這是一個事件,觸發條件就是滑鼠覆蓋在上面,比如:$('.text').hover(),然後就是事件,具體如下:
html:代碼如下
<p>這是觸發文字</p>
<img src='這是圖片'>
css:
img{
display:none
}
JQ:
$('p').hover( function(){
$('img').css('display','block');
});

㈢ jquery文字圖片切換效果

$("li").hover({
function(){

$(this).find("a").html("<img scr=\"圖片路徑\" />");

},

function(){

$(this).find("a").html("文字內容");

}

});

㈣ JQuery展開收起div 求大神幫忙添加上下箭頭圖片

<a href="#" id="toggle" class="top">展開<img src="img/1401957442.png" /> </a><br />

$("#toggle").click(function() {
$(this).html($("#content").is(":hidden") ? "收起"+"<img src='img/1401957442.png' />" : "展開"+"<img src='img/1401957442.png' />");
$("#content").slideToggle();
});

按你這種寫法,直接把三角的圖片跟那個文字寫在一起,要不然還真不太方便控制。把text方法改成html方法。
圖片路徑記得改

㈤ jquery點擊一個事件更換圖片,在點擊更換回來

這是你現在的結構;建議星星圖標可以用作背景圖片;

<!doctypehtml>
<html>
<head>
<metacharset="utf-8">
<title>無標題文檔</title>
<scripttype="text/javascript"src="http://apps.bdimg.com/libs/jquery/1.6.4/jquery.js"></script>
</head>
<body>
<style>
*{margin:0;padding:0;}
ul.stars{display:block;margin:100px100px30px;overflow:hidden;}
ul.starsli{display:block;float:left;padding:04px;cursor:pointer;}
ul.starsliimg{display:block;width:30px;height:30px;}
ul.starsliimg.full{display:none;}
ul.starsli.onimg.empty{display:none;}
ul.starsli.onimg.full{display:block;}
</style>
<script>
$(document).ready(function(e){
$("ul.starsli").click(function(){
$(this).toggleClass("on");
varstars=$("ul.stars").find("li.on").size();
$("input#stars").val(stars);
});
});
</script>
<formmethod="get">
<ulclass="stars">
<li>
<imgclass="empty"src="http://img2.imgtn.bdimg.com/it/u=3879777914,4025641504&fm=26&gp=0.jpg"/>
<imgclass="full"src="http://pic.wenwen.soso.com/p/20100131/20100131155623-694735656.jpg"/>
</li>
<li>
<imgclass="empty"src="http://img2.imgtn.bdimg.com/it/u=3879777914,4025641504&fm=26&gp=0.jpg"/>
<imgclass="full"src="http://pic.wenwen.soso.com/p/20100131/20100131155623-694735656.jpg"/>
</li>
<li>
<imgclass="empty"src="http://img2.imgtn.bdimg.com/it/u=3879777914,4025641504&fm=26&gp=0.jpg"/>
<imgclass="full"src="http://pic.wenwen.soso.com/p/20100131/20100131155623-694735656.jpg"/>
</li>
<li>
<imgclass="empty"src="http://img2.imgtn.bdimg.com/it/u=3879777914,4025641504&fm=26&gp=0.jpg"/>
<imgclass="full"src="http://pic.wenwen.soso.com/p/20100131/20100131155623-694735656.jpg"/>
</li>
<li>
<imgclass="empty"src="http://img2.imgtn.bdimg.com/it/u=3879777914,4025641504&fm=26&gp=0.jpg"/>
<imgclass="full"src="http://pic.wenwen.soso.com/p/20100131/20100131155623-694735656.jpg"/>
</li>
</ul>
<inputtype="hidden"id="stars"name="stars"/>
<inputtype="submit"value="提交"style="margin:0100px;">
</form>
</body>
</html>

最好的方式是把圖片處理一下作為ul的背景圖,通過點擊li獲取索引值來改變ul的背景圖片位置;不能上傳附件了。。還是上代碼吧。。

<!DOCTYPEHTML>
<html>
<metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/>
<metahttp-equiv="X-UA-Compatible"content="IE=EmulateIE7"/>
<metaname="keywords"content=""/>
<metaname="description"content=""/>
<title>評價</title>
<scripttype="text/javascript"src="http://apps.bdimg.com/libs/jquery/1.6.4/jquery.js"></script>
<script>
$(document).ready(function(){
//星級評分
$("formpspan.radiolabel.radio").click(function(){
$(this).parent("span.radio").css("background-position-y",-($(this).index()*19)+"px");
});
});
</script>
<style>
*{margin:0;padding:0;}
formp{display:block;overflow:hidden;padding:10px20px;}
formplabel{display:block;height:36px;line-height:36px;color:#444;font-size:14px;float:left;}
formpspan.radio{display:block;width:150px;height:19px;background:url(stars.png)left0pxno-repeat;float:left;margin:8px00;}
formpinput.radio{display:none;}
formplabel.radio{width:20%;height:100%;margin:0;cursor:pointer;}
forminput.btn{display:block;width:210px;height:36px;line-height:36px;*line-height:normal;color:#fff;font-size:15px;background:#ffb81f;border:0;border-radius:6px;cursor:pointer;float:left;margin-top:10px;}
</style>
<body>

<form>
<p>
<label>服務態度:</label>
<spanclass="radio">
<inputclass="radio"type="radio"name="star1"value="0"checked/>
<labelclass="radio"for="star11"></label>
<labelclass="radio"for="star12"></label>
<labelclass="radio"for="star13"></label>
<labelclass="radio"for="star14"></label>
<labelclass="radio"for="star15"></label>
<inputid="star11"class="radio"type="radio"name="star1"value="1"/>
<inputid="star12"class="radio"type="radio"name="star1"value="2"/>
<inputid="star13"class="radio"type="radio"name="star1"value="3"/>
<inputid="star14"class="radio"type="radio"name="star1"value="4"/>
<inputid="star15"class="radio"type="radio"name="star1"value="5"/>
</span>
</p>
<p>
<label>運輸速度:</label>
<spanclass="radio">
<inputclass="radio"type="radio"name="star2"value="0"checked/>
<labelclass="radio"for="star21"></label>
<labelclass="radio"for="star22"></label>
<labelclass="radio"for="star23"></label>
<labelclass="radio"for="star24"></label>
<labelclass="radio"for="star25"></label>
<inputid="star21"class="radio"type="radio"name="star2"value="1"/>
<inputid="star22"class="radio"type="radio"name="star2"value="2"/>
<inputid="star23"class="radio"type="radio"name="star2"value="3"/>
<inputid="star24"class="radio"type="radio"name="star2"value="4"/>
<inputid="star25"class="radio"type="radio"name="star2"value="5"/>
</span>
</p>
<p>
<label>貨款發放:</label>
<spanclass="radio">
<inputclass="radio"type="radio"name="star3"value="0"checked/>
<labelclass="radio"for="star31"></label>
<labelclass="radio"for="star32"></label>
<labelclass="radio"for="star33"></label>
<labelclass="radio"for="star34"></label>
<labelclass="radio"for="star35"></label>
<inputid="star31"class="radio"type="radio"name="star3"value="1"/>
<inputid="star32"class="radio"type="radio"name="star3"value="2"/>
<inputid="star33"class="radio"type="radio"name="star3"value="3"/>
<inputid="star34"class="radio"type="radio"name="star3"value="4"/>
<inputid="star35"class="radio"type="radio"name="star3"value="5"/>
</span>
</p>
<p>
<inputclass="btn"type="submit"value="提交"/>
</p>
</form>
</body>
</html>

附上圖片素材

㈥ jquery怎麼實現把一段帶圖片的文本里的圖片替換成其他文字!

1、使用正則替換

//聲明正則
varreg="<(img|a|p|b|div|br)\s*([\w]*=("|')([^"'<]*)("|')\s*)*(/>|>)";
//讀取文本
$.get('Scripts/data.txt').success(function(content){
//content就為文件data.txt的文本內容了,注意txt文件的編碼需要與html文件的編碼一///致,最好保存成utf-8

//替換操作
varresult=content.replace(reg,'你要替換的文字');
});

2、文本內容作為string字元串,然後使用indexof()查找ing標簽下標,img標簽長度,一個個的替換(很麻煩,不推薦)

㈦ 使用jquery更換圖片如何實現

一般是改css
$('#x').click(function(){
var img = $(this).css('background-image');
if(img =='xxx.png'){
img = 'yyy.png';
}else{
img='xxx.png';
}
$(this).css('background-image','url("'+img+'")')
})

㈧ jquery點擊改變背景圖片

css("background-image","url(image[n])");

問題出在這里了吧!
你這么寫不相當於 background-image:url(image[n]) 了么?

這樣試試:
$(".slider_image").css("background-image","url("+image[n]+")");

㈨ jquery怎麼實現點擊一個元素更換背景圖片,連續點擊永遠在2張圖片之間更換

實現的方法和操作步驟如下:

1、首先,打開html編輯器,創建一個新的html文件,例如index.html,然後引入jquery,如下圖所示。

閱讀全文

與jquery按文字改變圖片相關的資料

熱點內容
朱雨辰發型圖片 瀏覽:923
獅子3d高清圖片 瀏覽:573
簡單的讀書卡片大全圖片 瀏覽:238
頭像男生陽光清新圖片大全 瀏覽:806
鋼構廠房圖片大全 瀏覽:195
雪地背影女孩圖片 瀏覽:503
表示歡迎的動漫圖片 瀏覽:235
男生動漫帥氣的頭像圖片 瀏覽:499
櫻花圖片動漫手機壁紙 瀏覽:385
卡通動漫圖片狗 瀏覽:111
如何檢索生葯圖片 瀏覽:666
動漫女孩坐在肩上圖片 瀏覽:935
動漫兩個人物圖片高清 瀏覽:167
word怎麼把圖片一處摳出來 瀏覽:33
齊肩發型中長發圖片 瀏覽:185
小孩走路圖片卡通可愛圖片 瀏覽:645
qq文字個性名片圖片 瀏覽:686
張嘴吐舌頭動漫女孩圖片 瀏覽:414
胖女孩圖片可愛的胖女孩子卡通 瀏覽:522
時尚女短發型2016圖片 瀏覽:21