所以我有一个包含更多div的灯箱,当我点击一个时,我想将文本值显示在inputText中。
这是代码:
<h:form style="margin:55px; opacity:1;">
<h:panelGrid columns="1">
<p:inputText id="name"
style="width:400px; box-shadow: inset 0 0px 0px"
placeholder="Name: " />
<br />
<p:inputTextarea id="description"
style="width:400px; box-shadow: inset 0 0px 0px"
placeholder="Description: " rows="8" cols="35" />
<br />
<p:lightBox >
<p:inputText id="category_input" style="width:400px; box-shadow: inset 0 0px 0px"
placeholder="Category: " />
<br />
<f:facet name="inline">
<div id="categ_select" style="width: 600px; height: 300px; background-color: white; padding:30px">
<div id="categ_item" class="category_item">
<p>Auto - Moto - Nautic</p>
</div>
<div id="categ_item" class="category_item">
<p>Imobiliare</p>
</div>
<div id="categ_item" class="category_item">
<p>Electronice-Electrocasnice</p>
</div>
<div id="categ_item" class="category_item">
<p>Casa-Gradina</p>
</div>
<div id="categ_item" class="category_item">
<p>Moda-Frumusete</p>
</div>
<div id="categ_item" class="category_item">
<p>Afaceri-Servicii</p>
</div>
</div>
</f:facet>
</p:lightBox>
<p:inputText id="price"
style="width:400px; box-shadow: inset 0 0px 0px"
placeholder="Price: " />
<br />
<p:inputText id="city"
style="width:400px; box-shadow: inset 0 0px 0px"
placeholder="City: " />
<br />
</h:panelGrid>
</h:form>
这是我正在使用的jquery:
$('.category_item').click(function(){
var item = $(this).text();
console.log(item);
$('#category_input').val(item);
});
提前感谢您,请不要介意ID名称,因为我专注于功能,而不是名称和内容。
谢谢!