错误:“未捕获的TypeError:无法读取未定义的属性'replace'”?
jQuery(document).ready(function(){
var rep = jQuery(".abc")
.clone()
.wrap("<div></div>")
.parent().html()
.replace(/select/g,"ul")
.replace(/option/g,"li");
jQuery(".abc").replaceWith(rep);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
答案 0 :(得分:0)
我认为这符合预期:
private Button firstWindowButton;
public SecondWindow(Button firstWindowButton) {
this.firstWindowButton = firstWindowButton;
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
firstWindowButton.Click += firstWindowButton_Click;
}
void firstWindowButton_Click(object sender, RoutedEventArgs e)
{
lblShowUser.Content = "First window button clicked on: " + DateTime.Now.ToString();
}
<Label Name="lblShowUser" Content="" HorizontalAlignment="Left" Margin="275,175,0,0" VerticalAlignment="Top" Height="92" Width="205"/>
&#13;
jQuery(document).ready(function(){
var rep = jQuery(".abc")
.clone()
.wrap("<div></div>")
.parent().html()
.replace(/select/g,"ul")
.replace(/option/g,"li");
jQuery(".abc").replaceWith(rep);
});
&#13;
也许您错过了网页上的<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="abc">
<select>
<option>1</option>
<option>2</option>
</select>
</div>
元素。在这种情况下,.abc
将返回.html()
。