2012-11-19 108 views
0

文本屬性我有一個jquerymobile的應用程序,具有此標題代碼替換使用jQuery

@section header 
{ 
@Html.ActionLink("Cancelar", "DocsCancelar", "Docs", new { area = "Documentos" }, new { StrIdDocumento = "", data_icon="delete" }) 
<h1 id="NombreItem">Ubicacion 50 </h1> 
@Html.ActionLink("Grabar", "DocsGuardar", "Docs", new { area = "Documentos",StrIdDocumento = SessionBag.Current.StrIdDocumento }, new { data_icon="check" }) 
} 

我想在

<h1>****</h1> tag. 

更改文本我有這樣的jQuery的功能

$(data).find('NombreItem').each(function() { 
    $('#NombreItem').replaceWith($(this).text()); 
}) 

但是這個替換整個標籤,我唯一需要改變的是Ubicacion 50Ubicacion 70或類似的東西。

回答

1

只要做到:$('#NombreItem').text(newText);

+0

奇妙的是,jquery非常簡單,但我只是從它開始。 –

+0

怎麼樣改變一個屬性...有點像改變標籤的href? –

+1

@JuanPabloGomez'.attr(「href」,...)' –

0

爲什麼不id="replaceText"包裹Ubicacion文本在span標籤,然後只需更換整個標籤?