ยินดีต้อนรับคุณ, บุคคลทั่วไป กรุณา เข้าสู่ระบบ หรือ ลงทะเบียน

เข้าสู่ระบบด้วยชื่อผู้ใช้ รหัสผ่าน และระยะเวลาในเซสชั่น

ThaiSEOBoard.comพัฒนาเว็บไซต์Programmingช่วยด้วยครับ...css + jquery
หน้า: [1]   ลงล่าง
พิมพ์
ผู้เขียน หัวข้อ: ช่วยด้วยครับ...css + jquery  (อ่าน 986 ครั้ง)
0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้
นิติพงษ์
บุคคลทั่วไป
« เมื่อ: 28 กุมภาพันธ์ 2011, 11:51:14 »

 wanwan017
รบกวนดูติวเตอร์นี้ให้หน่อยครับ http://www.sohtanaka.com/web-d...ontal-sub-nav-with-css-jquery/
เเบบว่าต้องการดัดเเปลงให้ submenu มันโชว์เลย ไม่ต้องซ่อน
เเบบในภาพที่ผมทําไว้ นี้ครับ
บันทึกการเข้า
jdseo
บุคคลทั่วไป
« ตอบ #1 เมื่อ: 28 กุมภาพันธ์ 2011, 11:53:08 »

display:block; ครับ ง่ายนิดเดียว...แต่ยากเยอะ..อิอิ ล้อเล่นนะครับ
บันทึกการเข้า
bonshington
ก๊วนเสียว
*

พลังน้ำใจ: 47
ออฟไลน์ ออฟไลน์

กระทู้: 376



ดูรายละเอียด
« ตอบ #2 เมื่อ: 28 กุมภาพันธ์ 2011, 23:53:14 »

โค๊ด:
ต้นฉบับ
$(document).ready(function() {

$("ul#topnav li").hover(function() { //Hover over event on list item
 $(this).css({ 'background' : '#1376c9 url(topnav_active.gif) repeat-x'}); //Add background color + image on hovered list item
 $(this).find("span").show(); //Show the subnav
} , function() { //on hover out...
 $(this).css({ 'background' : 'none'}); //Ditch the background
 $(this).find("span").hide(); //Hide the subnav
});

});

ถ้าจะเอา li อันไหน ก็ใส่ id="pre_show" ลงไป
โค๊ด:
<li id="pre_show">

จากนั้น เอาอันนี้ไปต่อท้าย script
โค๊ด:
$(document).ready(function() {
 $("#pre_show").hover();
});
« แก้ไขครั้งสุดท้าย: 01 มีนาคม 2011, 00:00:59 โดย bonshington » บันทึกการเข้า
นิติพงษ์
บุคคลทั่วไป
« ตอบ #3 เมื่อ: 03 มีนาคม 2011, 19:57:05 »

โค๊ด:
ต้นฉบับ
$(document).ready(function() {

$("ul#topnav li").hover(function() { //Hover over event on list item
 $(this).css({ 'background' : '#1376c9 url(topnav_active.gif) repeat-x'}); //Add background color + image on hovered list item
 $(this).find("span").show(); //Show the subnav
} , function() { //on hover out...
 $(this).css({ 'background' : 'none'}); //Ditch the background
 $(this).find("span").hide(); //Hide the subnav
});

});

ถ้าจะเอา li อันไหน ก็ใส่ id="pre_show" ลงไป
โค๊ด:
<li id="pre_show">

จากนั้น เอาอันนี้ไปต่อท้าย script
โค๊ด:
$(document).ready(function() {
 $("#pre_show").hover();
});

ขอบคุงครับ +1
แต่ยังไม่ได้ครับ
เเท็บสีฟ้ามันยังไม่โชว์ ต้องการให้มันโชว์ถาวร
ไม่ต้องซ่อนหรือ hover อ่าครับ
บันทึกการเข้า
yoyokung
หัวหน้าแก๊งเสียว
*

พลังน้ำใจ: 143
ออฟไลน์ ออฟไลน์

กระทู้: 1,794



ดูรายละเอียด เว็บไซต์
« ตอบ #4 เมื่อ: 03 มีนาคม 2011, 20:05:12 »

แล้วมันมีหลายแถบคุณต้องการอย่างไรครับ

แบบว่า โชว์ตลอด แต่พอวางเม้าส์แล้วให้สลับเหมือนปกติ
บันทึกการเข้า

ขาย ฐานข้อมูล Flash Game กว่า 25,000 เกมส์ 5,000 บาท

ฉันรักเธอ เที่ยวไทย

สอนดึงเว็บ 30 ชั่วโมง / 5,000 บาท สุดยอดมาก
สอนดูดเว็บ 30 ชั่วโมง / HTML , CSS , jQuery , PHP
bonshington
ก๊วนเสียว
*

พลังน้ำใจ: 47
ออฟไลน์ ออฟไลน์

กระทู้: 376



ดูรายละเอียด
« ตอบ #5 เมื่อ: 03 มีนาคม 2011, 22:14:24 »

ต้นฉบับ
โค๊ด:
$(document).ready(function() {

$("ul#topnav li").hover(function() { //Hover over event on list item
 $(this).css({ 'background' : '#1376c9 url(topnav_active.gif) repeat-x'}); //Add background color + image on hovered list item
 $(this).find("span").show(); //Show the subnav
} , function() { //on hover out...
 $(this).css({ 'background' : 'none'}); //Ditch the background
 $(this).find("span").hide(); //Hide the subnav
});

});

โค๊ด:
$(document).ready(function() {

// แก้ code ให้โชว์ตลอด
$("ul#topnav li").mouseenter(function() { //Hover over event on list item
 var li = $(this);
 li.parent().children("li").find("span").hide();
 var span = li.find("span");
 span.css({ 'background' : '#1376c9 url(topnav_active.gif) repeat-x'}); //Add background color + image on hovered list item
 span.show(); //Show the subnav
};

// สั่งให้ตัวแรก โชว์
$("ul#topnav li:first").mouseenter();
// หรือ
//$("ul#topnav li#preshow").mouseenter();

});

ใช้ mouse enter ดีกว่า hover เพราะ hover มันจะ trigger ถี่ๆ ในขณะที่ mouse ลอยทับอยู่
ส่วน mouseenter จะ trigger ครั้งเดียวคือ เมื่อ ทouse เข้า
บันทึกการเข้า
หน้า: [1]   ขึ้นบน
พิมพ์