jQuery 如何使用jquery更改元素的位置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17421032/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to change position of element using jquery
提问by dsi
I have html stuff as below:
我有如下的 html 内容:
<div class="field-group">
<label for="customfield_10102">select list</label>
<select class="select" name="customfield_10102" id="customfield_10102">
<option value="-1">None</option>
</select>
</div>
<div class="field-group">
<label for="customfield_10103">select list1</label>
<select class="select" name="customfield_10103" id="customfield_10103">
<option value="-1">None</option>
</select>
</div>
any number of option as per configured. query:
根据配置的任意数量的选项。询问:
change the position of
<select class="select" name="customfield_10103" id="customfield_10103">
to append with<select class="select" name="customfield_10102" id="customfield_10102">
(with 40 px margin) and also have to change both select list's width.After that, remove
<div class="field-group"><label for="customfield_10103">select list1</label></div>
更改
<select class="select" name="customfield_10103" id="customfield_10103">
要附加的位置<select class="select" name="customfield_10102" id="customfield_10102">
(40 像素边距),并且还必须更改两个选择列表的宽度。之后,删除
<div class="field-group"><label for="customfield_10103">select list1</label></div>
Any one can suggest me , how i could achieve this using JQUERY?
任何人都可以建议我,我如何使用 JQUERY 实现这一目标?
NOTE: just for reference, i need such customization in JIRA custom field which can be achievable using jquery.
注意:仅供参考,我需要在 JIRA 自定义字段中进行此类自定义,这可以使用 jquery 实现。
Another related query:
另一个相关查询:
Below is HTML stuff:
以下是 HTML 内容:
<li id="rowForcustomfield_10102" class="item">
<div class="wrap">
<strong title="select list" class="name">select list:</strong>
<div id="customfield_10102-val" class="value type-select editable-field inactive"
data-fieldtype="select" title="Click to edit">
final2 <span class="overlay-icon icon icon-edit-sml" />
</div>
</div>
</li>
<li id="rowForcustomfield_10103" class="item">
<div class="wrap">
<strong title="select list1" class="name">select list1:</strong>
<div id="customfield_10103-val" class="value type-select editable-field inactive"
data-fieldtype="select" title="Click to edit">
1 <span class="overlay-icon icon icon-edit-sml" />
</div>
</div>
</li>
I want to remove "rowForcustomfield_10103" and just it's contained a element "customfield_10103-val" place at next to "customfield_10102-val" with some margin. so, after that it will look as below:
我想删除“rowForcustomfield_10103”,只是它包含一个元素“customfield_10103-val”,位于“customfield_10102-val”旁边,并带有一些边距。因此,之后它将如下所示:
`<li id="Li1" class="item">
<div class="wrap">
<strong title="select list" class="name">select list:</strong>
<div id="Div1" class="value type-select editable-field inactive"
data-fieldtype="select" title="Click to edit">
final2 <span class="overlay-icon icon icon-edit-sml" />
</div>
<div id="Div2" class="value type-select editable-field inactive"
data-fieldtype="select" title="Click to edit">
1 <span class="overlay-icon icon icon-edit-sml" />
</div>
</div>
</li>`
Please also let me know on this.
也请让我知道这一点。
have tried below but unable to change position:
已尝试以下但无法改变位置:
if(AJS.$("rowForcustomfield_10102").length > 0)
{
AJS.$("customfield_10102-val").after( AJS.$('customfield_10103-val'));
AJS.$('customfield_10103-val').css({ 'margin-left': '40px','width':'80px' })
AJS.$('customfield_10102-val').css({ 'width': '80px' });
AJS.$("#rowForcustomfield_10102 .name").html(null);
AJS.$("#rowForcustomfield_10103 .name").html(null);
}
回答by sangram parmar
try this
尝试这个
$("#customfield_10102").after($('#customfield_10103'));
$('#customfield_10103').css({ 'margin-left': '40px','width':'200px' })
$('#customfield_10102').css({ 'width': '200px' });
$('[for="customfield_10103"]').closest('.field-group').remove();