문제

Is there a way to dynamically change the content inside the tag?, throught jquery or javascript?

I am not using php or any server side script. I am using backbone.js and hence i have a .html file.

I have come to a situation where i would need to type in base path.

Like

<base href="www.google.com" />

I have searched around and i havent got anywhere.

Probably this is not possible at all, but just wanted to check it here in stackoverflow.

도움이 되었습니까?

해결책

Using jQuery. Here is jsFiddle I've made http://jsfiddle.net/uQVeN/

HTML:

<base href="www.google.com" />
<div id="valueBefore"></div>
<div id="valueAfter"></div>

JS:

$(document).ready(function(){
    $('#valueBefore').text( $('base').attr('href') );
    $('base').attr('href','kjhsgdkjahgdjkahgdf');
    $('#valueAfter').text( $('base').attr('href') );
});

Will produce:

www.google.com
kjhsgdkjahgdjkahgdf
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top