[WEB] 제이쿼리 또는 자바스크립트 클릭 시 객체/요소 속성 제어 또는 가져오기.
1. 클래스 중에 클릭한 객체의 속성값 가져오기
$(".l_idx").on("click",function(){
var l_idx = $(this).attr('value');
});
2. 로딩 시 객체의 속성값 추가 또는 변경하기
$( document ).ready(function() {
$("#1").attr('class','active');
$("#video_1").attr('class','tab-pane fade active in');
});
3. 테이블에서 하나의 Row 값 가지고 와서 데이터 보내기
1) 해당 Row에 있는 버튼 클릭
$("#datatable .fa-book").bind("click", function() {
var oData = 함수명($(this).parent().parent()); //이넘이 자신 상위에 상위 요소 가지고 옴.
데이터보낼함수(oData);
});
2)해당 Row 값 변수에 넣고 보내기
function 함수명(oTr){
if(oTr) {
var $Tr = $(oTr);
oReturn = {
"변수1" : $Tr.attr("객체1"),
"변수2" : $Tr.find("td[name=객체2]").text(),
"변수3" : $Tr.find("td[name=객체3]").text(),
"변수4" : $Tr.find("td[name=객체4]").text(),
"변수5" : $Tr.find("td[name=객체5]").text(),
"변수6" : $Tr.find("td[name=객체6]").text(),
"변수7" : $Tr.attr("객체7"),
"변수8" : $Tr.attr("객체8"),
"변수9" : ($Tr.find("td[name=객체9]").text() == "Y" ? "Y" : "N"),
"변수10" : ($Tr.attr("객체10")),
"변수11" : $Tr.attr("객체11"),
"변수12" : ($Tr.attr("객체12") == "Y" ? "Y" : "N")
};
}
return oReturn;
}
3)모달에 데이터 넣기
function BookMasterInitModal(oData) {
var $Frm = $("#frmBook");
$Frm[0].reset(); //모달 초기화
$Frm.find("[name=객체1]").val(oData.변수1);
$Frm.find("[name=객체2]").val(oData2.변수);
$Frm.find("[name=객체3]").val(oData3.변수).attr("readOnly", false);
$Frm.find("[name=객체4]").val(oData4.변수);
$Frm.find("[name=객체5]").val(oData5.변수);
$Frm.find("[name=객체6]").val(oData6.변수);
$Frm.find("[name=객체7]").val(oData7.변수);
$Frm.find("[name=객체8]").val(oData8.변수);
$Frm.find("[name=객체9]").val(oData9.변수);
$Frm.find("[name=객체10]").text(oData10.변수);
$Frm.find("[name=객체11]")[0].checked = (oData11.변수=="Y" ? true : false);
$Frm.find("[name=객체12]")[0].checked = (oData12.변수=="Y" ? true : false);
}
4.)class 중에 원하는 값 가져오기(active)
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="NHK_book">
.....
</>div
</div>
value_ex = $("ul.nav.nav-tabs").find("li.active").text();
$("[name=excel_v]").val(value_ex); //input hidden 넣음.
$(".l_idx").on("click",function(){
var l_idx = $(this).attr('value');
});
2. 로딩 시 객체의 속성값 추가 또는 변경하기
$( document ).ready(function() {
$("#1").attr('class','active');
$("#video_1").attr('class','tab-pane fade active in');
});
3. 테이블에서 하나의 Row 값 가지고 와서 데이터 보내기
1) 해당 Row에 있는 버튼 클릭
$("#datatable .fa-book").bind("click", function() {
var oData = 함수명($(this).parent().parent()); //이넘이 자신 상위에 상위 요소 가지고 옴.
데이터보낼함수(oData);
});
2)해당 Row 값 변수에 넣고 보내기
function 함수명(oTr){
if(oTr) {
var $Tr = $(oTr);
oReturn = {
"변수1" : $Tr.attr("객체1"),
"변수2" : $Tr.find("td[name=객체2]").text(),
"변수3" : $Tr.find("td[name=객체3]").text(),
"변수4" : $Tr.find("td[name=객체4]").text(),
"변수5" : $Tr.find("td[name=객체5]").text(),
"변수6" : $Tr.find("td[name=객체6]").text(),
"변수7" : $Tr.attr("객체7"),
"변수8" : $Tr.attr("객체8"),
"변수9" : ($Tr.find("td[name=객체9]").text() == "Y" ? "Y" : "N"),
"변수10" : ($Tr.attr("객체10")),
"변수11" : $Tr.attr("객체11"),
"변수12" : ($Tr.attr("객체12") == "Y" ? "Y" : "N")
};
}
return oReturn;
}
3)모달에 데이터 넣기
function BookMasterInitModal(oData) {
var $Frm = $("#frmBook");
$Frm[0].reset(); //모달 초기화
$Frm.find("[name=객체1]").val(oData.변수1);
$Frm.find("[name=객체2]").val(oData2.변수);
$Frm.find("[name=객체3]").val(oData3.변수).attr("readOnly", false);
$Frm.find("[name=객체4]").val(oData4.변수);
$Frm.find("[name=객체5]").val(oData5.변수);
$Frm.find("[name=객체6]").val(oData6.변수);
$Frm.find("[name=객체7]").val(oData7.변수);
$Frm.find("[name=객체8]").val(oData8.변수);
$Frm.find("[name=객체9]").val(oData9.변수);
$Frm.find("[name=객체10]").text(oData10.변수);
$Frm.find("[name=객체11]")[0].checked = (oData11.변수=="Y" ? true : false);
$Frm.find("[name=객체12]")[0].checked = (oData12.변수=="Y" ? true : false);
}
4.)class 중에 원하는 값 가져오기(active)
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="NHK_book">
.....
</>div
</div>
value_ex = $("ul.nav.nav-tabs").find("li.active").text();
$("[name=excel_v]").val(value_ex); //input hidden 넣음.
댓글
댓글 쓰기