基于jQuery插件實(shí)現(xiàn)點(diǎn)擊小圖顯示大圖效果
本文實(shí)例為大家分享了基于jQuery實(shí)現(xiàn)點(diǎn)擊小圖顯示大圖效果,供大家參考,具體內(nèi)容如下
顯示以下效果:
點(diǎn)擊任意一張圖片會顯示大圖:
1、前臺界面
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="練習(xí).WebForm1" %> <!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 runat="server"> <title></title> <style type="text/css"> #mydiv ul{ list-style-type:none;} #mydiv ul li{ display:inline;} #mydiv{ width:500px; border:solid 1px #444; background-color:#333;} </style> <link href="css/nf.lightbox.css" rel="stylesheet" type="text/css" /> <script src="Jquery1.7.js" type="text/javascript"></script> <script src="js/NFLightBox.js" type="text/javascript"></script> <script type="text/javascript"> $(function () { //var settings = { containerResizeSpeed: 3000 }; $('#mydiv ul a').lightBox({ containerResizeSpeed: 1000 }); }) </script> </head> <body> <form id="form1" runat="server"> <div id="mydiv" runat="server"> </div> </form> </body> </html>
2、后臺代碼
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; using System.Data; using System.Text; namespace 練習(xí) { public partial class WebForm1 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { LoadData(); } } private void LoadData() { string constr = "data source=LOVE-PC\\SQLEXPRESSPC;initial catalog=BoKe;user id=sa;password=admin"; using (SqlConnection conn = new SqlConnection(constr)) { using (SqlCommand cmd =conn.CreateCommand()) { conn.Open(); cmd.CommandText = "select BigImgUrl,SmallImgUrl from T_Photo"; SqlDataAdapter adapter = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); adapter.Fill(dt); StringBuilder sb = new StringBuilder(); sb.Append("<ul>"); for (int i = 0; i < dt.Rows.Count; i++) { sb.Append("<a href=" + dt.Rows[i]["BigImgUrl"] + ">");//添圖片路徑 sb.Append("<li>"); sb.Append("<img src=" + dt.Rows[i]["SmallImgUrl"] + ">");//添圖片路徑 sb.Append("</li>"); sb.Append("</a>"); } sb.Append("</ul>"); mydiv.InnerHtml = sb.ToString(); } } } } }
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助。
- jQuery實(shí)現(xiàn)等比例縮放大圖片讓大圖片自適應(yīng)頁面布局
- 基于jquery的防止大圖片撐破頁面的實(shí)現(xiàn)代碼(立即縮放)
- jQuery+css實(shí)現(xiàn)的點(diǎn)擊圖片放大縮小預(yù)覽功能示例【圖片預(yù)覽 查看大圖】
- jQuery實(shí)現(xiàn)鼠標(biāo)滑過商品小圖片上顯示對應(yīng)大圖片功能【測試可用】
- jQuery實(shí)現(xiàn)鼠標(biāo)滑過預(yù)覽圖片大圖效果的方法
- jQuery實(shí)現(xiàn)大圖輪播
- jQuery實(shí)現(xiàn)的小圖列表,大圖展示效果幻燈片示例
- jquery插件jquery.LightBox.js實(shí)現(xiàn)點(diǎn)擊放大圖片并左右點(diǎn)擊切換效果(附demo源碼下載)
- jQuery實(shí)現(xiàn)點(diǎn)擊小圖片淡入淡出顯示大圖片特效
- jQuery實(shí)現(xiàn)點(diǎn)擊查看大圖并以彈框的形式居中
- jquery實(shí)現(xiàn)移動端點(diǎn)擊圖片查看大圖特效
- jQuery實(shí)現(xiàn)點(diǎn)擊小圖顯示大圖代碼分享
- jquery 圖片點(diǎn)擊放大預(yù)覽功能詳解
相關(guān)文章
jquery如何獲取元素的滾動條高度等實(shí)現(xiàn)代碼
這篇文章主要介紹了jquery如何獲取元素的滾動條高度等實(shí)現(xiàn)代碼,需要的朋友可以參考下2015-10-10

解決jquery插件:TypeError:$.browser is undefined報(bào)錯的方法

簡潔實(shí)用的BootStrap jQuery手風(fēng)琴插件

jquery實(shí)現(xiàn)圖片裁剪思路及實(shí)現(xiàn)

jQuery對底部導(dǎo)航進(jìn)行跳轉(zhuǎn)并高亮顯示的實(shí)例代碼